[C#.NET] Inheritance - can i do this?

Are you at Birmingham uni then?
I applied there, probably for the course you're doing now.
I was umming and ahhing between Nottingham and Birmingham as my first choice, but in the end the campus at Nottingham won me over though and I went there.

God, that was 10 years ago now :(

Yep – Theoretical Physics and Applied Maths, first year :)

Funny, it was Birmingham's campus that made won me over. Never seen Nottingham though.
 
This was an incredibly long thread for something that is simply

1) Use Polymorphism
2) Use an If statement to choose which dervied class to instantiate.

:p

Never got on board with all these "design patterns". I always just code it how it's required.
 
Never got on board with all these "design patterns". I always just code it how it's required.

Are you saying that using design patterns is not required?
I would agree that there is a time and place for following a pattern, half the skill is knowing when to follow a particular method, but design patterns certainly have their place.

While it may seem like unneccesary overhead if you are working on a small application, if you have a 50 man team coding a large enterprise app then having everyone simply 'code it how it's required' will leave you with a complete mess of an application.
I've seen it before and it's not pretty.

This is why a skilled architect is needed to give overall direction and mandate the use of particular design patterns in certain circumstances.
 
While it may seem like unneccesary overhead if you are working on a small application, if you have a 50 man team coding a large enterprise app then having everyone simply 'code it how it's required' will leave you with a complete mess of an application.
I've seen it before and it's not pretty.

This is why a skilled architect is needed to give overall direction and mandate the use of particular design patterns in certain circumstances.

Totally agree, I'm just not used to them as all I code are personal apps or projects for uni. I accept when I enter an enterprise development project I will have to conform to standards, I just didn't expect whole code patterns and structures to be enforced, just naming conventions and commenting of code.
 
I just didn't expect whole code patterns and structures to be enforced, just naming conventions and commenting of code.

If you didn't have patterns and structures enforced you'd end up with a complete mangled mess of code on a team with anything more than a few developers.
It's the architect's job to ensure to design the overall plan and ensure that the application is being developed to specification.

It might be simple things such as using facades above the data access layer, making sure you adhere to strict layering and so forth or could be more descriptive about how to do things in which case.

I'm sure you can imagine that if 10 developers are working on a project then even if naming standards and comments are synchronisde there is still a huge potential for problems if they aren't aligned as to how the application should be structured.
 
Never got on board with all these "design patterns". I always just code it how it's required.

You probably are using design patterns without even realising. It is difficult not to be.

But even still you really should learn design patterns and document accordingly.

Pretty much any non-junior developer interview will ask about design patterns.
 
I'll make sure it is one of the things I learn over the next year before I apply to graduate positions then. I've had no real formal teaching for programming past the usual introduction to control structures like loops, data structures and OOP.
 
You can use Polymorphism to do just that.
Polymorphism is a feature of inheritance, it lets you create a class based on whatever condition and this class can be of either derived type you want but it's still your base class, just "casted" as either class a or class b.

Here is an explanation of it on msdn for c#
http://msdn.microsoft.com/en-us/library/ms173152(VS.80).aspx

ps: i personnaly dont know that well c# so i dont know if its really what you want but if i understood your explanation correctly it's just that you need
 
Back
Top Bottom