|
GateKeeper22 wrote: To me it isn't worth the extra work because we aren't really getting anything out of it expect another layer.
Sounds like a good idea to delay it until you do need it.
How much hours (and thus, money) would your co-worker spend on implementing it, and what benefit does he see in having that layer that's worth that cost?
Bastard Programmer from Hell
|
|
|
|
|
He would just add it to code generation so it wouldn't cost anytime. I haven't really gotten a good answer on what benefits it would give us. He just says it would be easy to generate and not take much time to implement so why not do it. To me that isn't a very good answer. I need to see the value that the layer will give us before I implement it. I would rather implement it on a case by case bases.
|
|
|
|
|
GateKeeper22 wrote: He would just add it to code generation so it wouldn't cost anytime.
"Does not cost any time"? So you are sure that it doesn't need maintenance and will not cause bugs?
GateKeeper22 wrote: I haven't really gotten a good answer on what benefits it would give us.
That makes it simple; we can generate a 2Gb data-file with random contents. That doesn't have much benefit either.
GateKeeper22 wrote: He just says it would be easy to generate and not take much time to implement so why not do it.
..because it doesn't add any value to the project, only extra code. That code has to be tested, and not having that extra load of code means that there cannot be any bugs in there
Bastard Programmer from Hell
|
|
|
|
|
That is a good point about adding more bugs even if it is generated. Thank you for the info. I am adding all of your points to my argument. I am also glad to see that I am not the only one out there that would be against this.
|
|
|
|
|
GateKeeper22 wrote: He would just add it to code generation so it wouldn't cost anytime.
That means something needs to change.
And you suggested that you are adding a layer and I use a lot of code generation and I can't think of a single example where adding a layer is a trivial fix.
GateKeeper22 wrote: He just says it would be easy to generate and not take much time to implement so
why not do it.
Nonsense.
Almost everything in programming is easy. It is the sum of the parts that means that software costs money. Every addition costs money.
Nothing that you have described suggests that this will have any net benefit. It certainly doesn't meet a business need. And it doesn't seem to meet any implementation need. So the other developer is attempting to rationalize some idealized view of how the world should be and ignoring the realities of large scale development.
|
|
|
|
|
That is what I am thinking. We just took a class that had view models in it so now he wants to implement them. I have pretty much shot him down on it and I think the rest of the team is behind me on it. But only time will tell. Posting on this form helped me to realize that I am correct it is just adding another layer when one isn't needed. At least for the project we are currently working on it isn't. In future projects there may be a benefit to using them.
|
|
|
|
|
If the reason is to remove presentation logic from the presentation layer ie sorting, FullName things like that. It sounds like a good idea.
If the reason is because you are using an ORM and this means you can blow away the entities and recreate without losing that 0.1% of logic, it also sounds like a good idea.
Doing it for the sake of it doesn't sound like a good idea.
"You get that on the big jobs."
|
|
|
|
|
sexy girlï¼video for adult ï¼ more than 30 videos.http://sharecash.org/download.php?file=2531204
|
|
|
|
|
In a software for a company, we usually have customers, employees and suppliers in what regards humans.
Therefore a reasonable (meaning a good one) OOP approach would be to have a class 'Persons' with attributes such as name, surname, address etc. and then let the classes 'Customers', 'Employees' and 'Suppliers' derive from the class 'Persons'.
But, on a second thought there is a problem. How do we deal with customers and suppliers which are companies?
|
|
|
|
|
And what if yet another kind of organisation knocks at your door? The government, for example. Perhaps you should get yourself some inspiration from how lawyers deal with different kinds of 'entities'. The real question still is wether or not you are overdesigning, just for design's sake.
And from the clouds a mighty voice spoke: "Smile and be happy, for it could come worse!"
And I smiled and was happy And it came worse.
|
|
|
|
|
You could have a base class called Contact which would have properties like Name, Address1, Address2, City, Email etc. Then your other classes would Inherit from this class, with the Employee class just having extra Propeties FirstName and Surname, and concatenating these two to provide the Name property, whereas Customer and Supplier would just use Name as Company Name.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Thanks for your answers.
I was reading Entity Framework and this is how the question arose: in the database we usually have a table customers and a table employees.
Using EF we would get two separate classes for those groups and I was wondering how to deal with inheritance. It seems to me that by using EF we coulnd't use inheritance at all. But this maybe another story...
|
|
|
|
|
Well, one thing I would advise you to change is the idea that you would put the address in that base class. What happens if your derived class requires multiple addresses? Just something to ponder.
|
|
|
|
|
The real problem is that you haven't defined the problem domain. You can't define your entities if you haven't defined the domain.
As an example an small grocery store certainly has customers, employees and suppliers just like an multi-national corporation does.
But the grocery store is unlikely to care about any of that if your goal is to write a POS application.
That said however it is unlikely that a problem domain that needed a single application that deals with those three entities would use a base class for all of them.
And really unlikely if the problem domain called for multiple applications.
|
|
|
|
|
A reasonable exercise at this point would be to identify the characteristics that you wish to associate with each of the different types. You may well find that there is an hierarchy that you have missed.
From experience, there should be a Person that is used to represent a physical being [and maybe a role in some cases] and an Organisation to represent companies [which will have Person contacts.
Customer is abstract, as it can be a Person or an Organisation , and will also reference the list of Address es.
For your problem domain, these might not all be needed, but they are a good starting point. You need to analyse how you will be using them, before you can decide how they will be used.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
Nagy Vilmos wrote: From experience, there should be a Person that is used to represent a physical being [and maybe a role in some cases] and an Organisation to represent companies [which will have Person contacts.
Do you mean in a form of nested classes?
|
|
|
|
|
nstk wrote: Do you mean in a form of nested classes?
You are looking at this problem from the wrong direction; forget about the types of classes you need. First define what the problem is and what general process is needed to solve it. Then define the users (people, organisations etc) and what properties they may need. From that information you can start to think about the different classes that will work together to solve the business problem. They may or may not be based on a single base class, but that is not a primary consideration.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I understand what you are saying but there is no real project. What I am really trying to do, is to find out why and where to use a base class in a hypothetical (but indeed very common) design problematic of, let's say, an ERP software.
If we narrow the problem to customers and employees, and assuming that customers are only individuals, it is obvious that both are persons, therefore a base class Persons and two inherited classes of Customers and Employees seems to be very reasonable.
But do we need to build a base class in our programme and if yes why? What is the real practical purpose of doing so? In my opinion this generalization of our two "real" classes seems to complicate designing without any having any profit from it.
That is my real question to the forum (although some of the answers above have already answered that too).
|
|
|
|
|
Sorry but you are asking for a tutorial on OOP; take a look at some of these links[^] which should help you.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Richard MacCutchan wrote: Sorry but you are asking for a tutorial on OOP
Well, not really. I 've read already many books about OOP, even studied and done some programmes. I found out that there can be solutions and concepts which vary a lot. In the above example there could be two solutions with or without inheritance between the classes I mentioned. And both could be acceptable and good. Both? Maybe? THat's why I asked here, to get answers from more experienced members. This cannot be done in a tutorial.
Thanks for the links.
|
|
|
|
|
If you want a good insight into design, try The Gang of Four[^], it provides some very good non-language specific information. If you are serious about design, I would suggest it as a must-have.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
nstk wrote: What I am really trying to do, is to find out why and where to use a base class
in a hypothetical (but indeed very common) design problematic of, let's say, an
ERP software.
Again...you start with the problem domain and it defines the classes.
If you don't have a problem domain then you cannot defined classes.
nstk wrote: But do we need to build a base class in our programme and if yes why?
Because the problem domain has requirements that specify that sort of implementation. Or because the problem domain lead to a specific implmentation and that implementation is best implemented that way.
|
|
|
|
|
No. I mean as candidate classes.
Begin by writing out in plain English [other languages are available] what you want to do. As an example, your system could be described thus:
Requirements: Provide software to manage the relationships between the company and it's suppliers and customers. All the contacts can be either individual people or companies. Any company will have one or more contact. Orders are recieved from customers and placed with suppliers for the provision of Widgets and associated products. Every order received will result in an invoice being raised by the accounting system. Orders placed with suppliers will be filled and invoices for payment will be sent to the accounting system. Each order [inbound or outbound] will have a billing address and a delivery address, these need not be the same. Each customer can have default addresses associated with it.
From this initial requirement, you can take out all the nouns and noun phrases. These are your candidate classes. The next stage is to decide which ones are classes in their own right and which are attributes. Often a lot of candidates can be reduced. As an exercise, I would recommend giving this a go and see where it takes you.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
Thanks for your effort, I really appreciate this great help. I will indeed develop this as an exercise and if there is something to discuss I will write it here.
|
|
|
|
|
Here is a simple set of candidate classes:
+------------+
| Customer |
| |
+------------+
|
v
+------------+ +------------+ +------------+
| Supplier |--->| Contact |--->| Person |
| | | <Abstract> | | |
+------------+ +------------+ +------------+
|
+------+--------+
| impliments |
+------------+ +------------+
| Company | | Individual |
| | | |
+------------+ +------------+
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|