Re: public abstract static ...
- From: "Joanna Carter [TeamB]" <joanna@xxxxxxxxxxxx>
- Date: Thu, 23 Mar 2006 15:52:05 -0000
"pali" <pali@xxxxxxxxxxxxxxxxxxxxxxxxx> a écrit dans le message de news:
503F4C34-9142-4247-9D7E-BCFA9D2F22A7@xxxxxxxxxxxxxxxx
| Yes, i know this is the limitation, I'm asking why? Is that a by-design
choice?
I guess so, Delphi has virtual static methods.
| I don't think it's meaningful to instantiate an instance of an object only
| to be able to read/delete it from the store.
| My typical class would look like this:
| public class Customer : EntityBase
| {
| public static Customer GetByID(int id) {}
| public void Save() {}
| public static void Delete(int id) {}
| }
| In this case i don't see a reason to instantiate an object if I want to
get
| it from the database by id anyway. Same for the delete, I don't want to
have
| to get an entity from the database just to be able to delete it.
| I want to put the signatures of those methods in the parent abstract
class,
| so I can get/save/delete them in a generic way...
Then how about factoring out the retrieval behaviour, which I would say
doesn't belong in the Customer class and use an Object Persistence Framework
instead ?
If you are using .NET 2.0, you can have methods on it like :
public class ObjectStore
{
public objectT RetrieveObject<objectT>(int Id)
{
...
}
...
}
Although I would also argue that most times you could retrieve a browsing
list for a criteria and then choose one object. That way you don't need to
know the ID outside of the OPF.
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer
.
- Follow-Ups:
- Re: public abstract static ...
- From: pali
- Re: public abstract static ...
- References:
- Re: public abstract static ...
- From: Joanna Carter [TeamB]
- Re: public abstract static ...
- Prev by Date: Re: Pre Screening Questions for a C# developer
- Next by Date: Re: Smo + remote Backup fails...
- Previous by thread: Re: public abstract static ...
- Next by thread: Re: public abstract static ...
- Index(es):
Relevant Pages
|