Click here to Skip to main content
15,889,200 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: .NET Framework Class Library Pin
Scott Dorman25-Mar-08 15:39
professionalScott Dorman25-Mar-08 15:39 
GeneralRe: .NET Framework Class Library Pin
Mark Salsbery25-Mar-08 16:01
Mark Salsbery25-Mar-08 16:01 
GeneralTracing internal method calls in aspect oriented programming Pin
mercurysmiles20-Mar-08 23:59
mercurysmiles20-Mar-08 23:59 
QuestionHow to sign the soap body in WCF Pin
konkola19-Mar-08 22:51
konkola19-Mar-08 22:51 
AnswerRe: How to sign the soap body in WCF Pin
MrMundial21-Apr-10 4:31
MrMundial21-Apr-10 4:31 
GeneralRe: How to sign the soap body in WCF Pin
Rick Piovesan15-Oct-10 3:18
Rick Piovesan15-Oct-10 3:18 
GeneralRe: How to sign the soap body in WCF Pin
MrMundial21-Oct-10 3:20
MrMundial21-Oct-10 3:20 
QuestionObject Consistency Problem Pin
Thanks for all the fish19-Mar-08 22:23
Thanks for all the fish19-Mar-08 22:23 
Hi all, Cool | :cool:

first exuse me please for my english, it is not a native.

here is my question Confused | :confused: :

say you have some class hierarchy


abstract class Warior<br />
{<br />
    String Description;<br />
    Armor armor;<br />
    Weapon weapon;<br />
 <br />
 <br />
    //Adittional Get/Set Properties<br />
 <br />
}<br />
 <br />
class HumanWarior : Warior<br />
{<br />
        <br />
}<br />
 <br />
class AlienWarior : Warior<br />
{<br />
 <br />
}<br />
 <br />
class GenericWarior : Warior<br />
{<br />
 <br />
}<br />
 <br />
 <br />
abstract class Armor<br />
{<br />
 <br />
}<br />
 <br />
abstract class Weapon<br />
{<br />
 <br />
}<br />
 <br />
 <br />
class AlienArmor : Armor<br />
{<br />
 <br />
}<br />
 <br />
class AlienWeapon : Weapon<br />
{<br />
 <br />
}<br />
 <br />
class HumanArmor : Armor<br />
{<br />
 <br />
}<br />
 <br />
class HumanWeapon : Weapon<br />
{<br />
 <br />
}


Given that hierarchy there can be many different objects of HumanWorior or AlienWorier type.
Everyone of them can contain Armor and Weapon objects of two presented concrate types.
the problem is that not all of the posible combinations are logicaly true. for example
HumanWorior can't contain AlienArmor or AlienWeapon. Also GenericWarior can contain both types
of Armor and Weapon but not two of them togather. For example GenericWarior can't contain
AlienArmor with HumanWorior.

How can you ensure that all the objects of type HumanWorior, AlienWorior or GenericWorior will be consistent during their entire lifetime cycle. How can you enforce a creation of logicaly corrected objectes only and mantain their correct state later on, according to defined set of
rules like: HumanWorior will contain only human devices.


here some code examples:


HumanArmor letherArmor = new HumanArmor();<br />
HumanWeapon longBow = new HumanWeapon();<br />
AlienWeapon plasmaPistol = new AlienWeapon(); <br />
AlienArmor MagneticShild = new AlienArmor();<br />
 <br />
HumanWorior humanWorior = new HumanWorior("Bob", letherArmor, longBow);<br />
humanWorior.Weapon = plasmaPistol; // here i need some error throw, i guess it should be an exception but if you know some other suitable technique for that porpose, it is fine.<br />
 <br />
 <br />
GenericWorior genWorior1 = new GenericWorior("SuperMan", letherArmor, longBow); // OK<br />
GenericWorior genWorior2 = new GenericWorior("SuperMan", MagneticShild, plasmaPistol); // OK<br />
GenericWorior genWorior3 = new GenericWorior("SuperMan", MagneticShild, longBow); // Error


i guess there is a solution at runtime with throwing an exeption but
if there a solution early at compile time for that problem.

thnx in advance. Smile | :)
GeneralRe: Object Consistency Problem Pin
Pete O'Hanlon20-Mar-08 0:54
mvePete O'Hanlon20-Mar-08 0:54 
GeneralRe: Object Consistency Problem [modified] Pin
PIEBALDconsult20-Mar-08 16:46
mvePIEBALDconsult20-Mar-08 16:46 
GeneralRe: Object Consistency Problem Pin
Pete O'Hanlon21-Mar-08 11:18
mvePete O'Hanlon21-Mar-08 11:18 
GeneralRe: Object Consistency Problem Pin
PIEBALDconsult21-Mar-08 12:55
mvePIEBALDconsult21-Mar-08 12:55 
GeneralRe: Object Consistency Problem Pin
Derek Bartram21-Mar-08 15:29
Derek Bartram21-Mar-08 15:29 
GeneralRe: Object Consistency Problem Pin
Ray Cassick25-Mar-08 11:35
Ray Cassick25-Mar-08 11:35 
QuestionUsing Certificates with c# and ASP.NET Pin
sfog19-Mar-08 11:10
sfog19-Mar-08 11:10 
GeneralCross post - please ignore Pin
pmarfleet19-Mar-08 11:16
pmarfleet19-Mar-08 11:16 
QuestionWhat do you mean you can't find the assembly? Pin
FyreWyrm18-Mar-08 15:13
FyreWyrm18-Mar-08 15:13 
GeneralRe: What do you mean you can't find the assembly? Pin
led mike19-Mar-08 5:32
led mike19-Mar-08 5:32 
GeneralRe: What do you mean you can't find the assembly? Pin
PIEBALDconsult19-Mar-08 11:55
mvePIEBALDconsult19-Mar-08 11:55 
GeneralRe: What do you mean you can't find the assembly? Pin
led mike21-Mar-08 9:41
led mike21-Mar-08 9:41 
GeneralRe: What do you mean you can't find the assembly? Pin
FyreWyrm19-Mar-08 12:18
FyreWyrm19-Mar-08 12:18 
AnswerRe: What do you mean you can't find the assembly? Pin
FyreWyrm19-Mar-08 12:22
FyreWyrm19-Mar-08 12:22 
GeneralRe: What do you mean you can't find the assembly? Pin
leppie20-Mar-08 22:32
leppie20-Mar-08 22:32 
QuestionEmail address encoding upper ascii (umlaut) question. Pin
tdpollard18-Mar-08 8:56
tdpollard18-Mar-08 8:56 
GeneralRe: Email address encoding upper ascii (umlaut) question. Pin
pmarfleet18-Mar-08 11:28
pmarfleet18-Mar-08 11:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.