Re: desgin tables into objects or vice versa?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Elhanan" <emaayan@xxxxxxxxxxx> wrote in message
news:1138349688.217482.21710@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> hi..
>
> i'm a database kind of guy, when ever i apprached a new project i
> always looked at it from tables point of view, how can normlize
> correcly and them moved to the objects and desgined them accodging to
> the tables..
>
> i see that usually ppl go the other way, design objects and then desgin
> the tables..
>
> i was looking into my tables and usually i see i have column
> type_of_somthing in it. like request_type in requests table or
> order_type in orders tables, etc...
> i was wondering, whenever i see this type of columns would it be right
> to design a class tree according to it? for example abstract order
> class and each subclass would correspond to an order type.

If different types must be processed differently then inheritance and
virtual methods are probably good.

If the processing is the same apart from some extra fields the probably best
not to bother.

If the fields differ other than by addition then processing must be
different and inheritance and polymorphism would be good.

Sometimes it can be better to handle these issues by sticking with a request
type but rather than using switch or if...then..else you use a dictionary to
look how to process the data. The advantage of this method is that the
dictionary can be populated using resource files and reflection.



.



Relevant Pages

  • Re: Inheritance question
    ... I guess I did need to be a lot clearer on intent. ... I am trying to learn inheritance so i dont really know the questions to ask. ... public BaseClass() ... virtual methods to deal with per-type behaviors. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: error CS0621: virtual or abstract members cannot be private
    ... The OOP languages that are in the mainstream all encourage inheritance. ... They can't override your private virtual method, but you've still got a public method they are going to _want_ to override and instead are going to wind up hiding (which whatever you think about public virtual methods seems to me to be much worse). ... If you want to hide _all_ of the implementation, better to make the base class private to your factory as well, the virtual method protected, and expose the API as an interface. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: error CS0621: virtual or abstract members cannot be private
    ... The OOP languages that are in the mainstream all encourage inheritance. ... But I feel that most of the virtual methods in the .NET framework are not public but protected ... I could make the Base class constructor private so the nested classes can still derive from it but nobody else. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Pointer to virtual object on stack
    ... It is a very simple case of inheritance and dynamic binding. ... derived from clas A, which means that B 'isa' A, anytime an instance of ... > virtual methods then B's virtual methods. ...
    (comp.lang.cpp)