if I have an object, say a recipe, which is added to a database, whose
responsibility is it to add to the db? The recipe or something else?
Let's say I want to delete a recipe? Does the recipe kill itself? Or does
the database or something else do the removal?
Where does the responsibility lie?
Thanks. 7 1393
Usually, you will use the Layers pattern (see Buschmann) and you would
seperate the business object (recipe) from the CRUD code needed to insert or
delete it from the database (in the persistence layer)
The object itself is responsible for using the persistence layer, and for
knowing what methods to call to persist its data.
So, a recipe stores itself using the persistence layer, and a recipe deletes
itself using the persistence layer.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
".net lear" <asdfasdf> wrote in message
news:uu*************@TK2MSFTNGP12.phx.gbl... if I have an object, say a recipe, which is added to a database, whose responsibility is it to add to the db? The recipe or something else?
Let's say I want to delete a recipe? Does the recipe kill itself? Or does the database or something else do the removal?
Where does the responsibility lie?
Thanks.
ok thanks. I thought the recipe would be responsible but I don't know
anything about the persistence layer.
"Nick Malik [Microsoft]" <ni*******@hotmail.nospam.com> wrote in message
news:xe********************@comcast.com... Usually, you will use the Layers pattern (see Buschmann) and you would seperate the business object (recipe) from the CRUD code needed to insert
or delete it from the database (in the persistence layer)
The object itself is responsible for using the persistence layer, and for knowing what methods to call to persist its data.
So, a recipe stores itself using the persistence layer, and a recipe
deletes itself using the persistence layer.
-- --- Nick Malik [Microsoft] MCSD, CFPS, Certified Scrummaster http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not representative of my employer. I do not answer questions on behalf of my employer. I'm just a programmer helping programmers. -- ".net lear" <asdfasdf> wrote in message news:uu*************@TK2MSFTNGP12.phx.gbl... if I have an object, say a recipe, which is added to a database, whose responsibility is it to add to the db? The recipe or something else?
Let's say I want to delete a recipe? Does the recipe kill itself? Or
does the database or something else do the removal?
Where does the responsibility lie?
Thanks.
The recipe only tells you how to cook the dish, it has no concept of where
the recipe is stored in your kitchen. As it happens its stored in the
cookbook (the persistence or data layer). storing the recipe has nothing to
do with cooking the dish, so you should refrain from including that logic in
your business layer (the recipe) - ideally the cookbook would do the
deletions and inserts with the recipe being an argument passed to it as the
persistence layer as inserts and deletions are something that occur to your
cookbook not your recipe.
--
Regards
John Timney
ASP.NET MVP
Microsoft Regional Director
--
Regards
John Timney
ASP.NET MVP
Microsoft Regional Director
".net lear" <asdfasdf> wrote in message
news:uu*************@TK2MSFTNGP12.phx.gbl... if I have an object, say a recipe, which is added to a database, whose responsibility is it to add to the db? The recipe or something else?
Let's say I want to delete a recipe? Does the recipe kill itself? Or does the database or something else do the removal?
Where does the responsibility lie?
Thanks.
Well put!
"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... The recipe only tells you how to cook the dish, it has no concept of where the recipe is stored in your kitchen. As it happens its stored in the cookbook (the persistence or data layer). storing the recipe has nothing to do with cooking the dish, so you should refrain from including that logic in your business layer (the recipe) - ideally the cookbook would do the deletions and inserts with the recipe being an argument passed to it as the persistence layer as inserts and deletions are something that occur to your cookbook not your recipe.
Thanks a lot.
I'm just getting started with this concept, very used to procedural
programming.
Isn't the cookbook just a collection of recipes? In other words,
doesn't it inherit from recipe to some degree?
When you say "stored in the cookbook (persistence or data layer)", can
you elaborate? What does that mean?
John Timney (ASP.NET MVP) wrote: The recipe only tells you how to cook the dish, it has no concept of where the recipe is stored in your kitchen. As it happens its stored in the cookbook (the persistence or data layer). storing the recipe has nothing to do with cooking the dish, so you should refrain from including that logic in your business layer (the recipe) - ideally the cookbook would do the deletions and inserts with the recipe being an argument passed to it as the persistence layer as inserts and deletions are something that occur to your cookbook not your recipe.
-- Regards
John Timney ASP.NET MVP Microsoft Regional Director
-- Regards
John Timney ASP.NET MVP Microsoft Regional Director
".net lear" <asdfasdf> wrote in message news:uu*************@TK2MSFTNGP12.phx.gbl... if I have an object, say a recipe, which is added to a database, whose responsibility is it to add to the db? The recipe or something else?
Let's say I want to delete a recipe? Does the recipe kill itself? Or does the database or something else do the removal?
Where does the responsibility lie?
Thanks.
How it inherits depends on your encapsulation, and whether there is any
interaction between the cookbook and the recipe. In an ideal OO scanrio the
recipe should be self contained, telling you only how to make the dish. The
cookbook knows nothing about making the dish, thus it needs to inherit none
of the properties of the recipe to function as a cookbook - it only needs to
contain recipe objects, like a namespace containing lots of different
classes. The classes in the namespace can be interelated by existing in the
namespace, but need not know anything about each other unless thats how to
need the objects to interact. Connected to this, the way you serve the
recipe (the presentation (layer)) has nothing to do with how it is stored in
the cookbook (persistence (layer)) or how it is cooked (business (layer))
Mutli tiered or layered implementations perform different and self contained
elements of your programming logic, like your presentation layer knowing
about plates and cress but nothing about cooking times. Theres a very nice
and straingtforward explanation of multi tiered applications here that might
be worth taking a look at. http://www.dfpug.de/konf/konf_1999/g...ier/e_tier.htm
--
Regards
John Timney
ASP.NET MVP
Microsoft Regional Director
".net lear" <ms*********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com... Thanks a lot.
I'm just getting started with this concept, very used to procedural programming.
Isn't the cookbook just a collection of recipes? In other words, doesn't it inherit from recipe to some degree?
When you say "stored in the cookbook (persistence or data layer)", can you elaborate? What does that mean?
John Timney (ASP.NET MVP) wrote: The recipe only tells you how to cook the dish, it has no concept of where the recipe is stored in your kitchen. As it happens its stored in the cookbook (the persistence or data layer). storing the recipe has nothing to do with cooking the dish, so you should refrain from including that logic in your business layer (the recipe) - ideally the cookbook would do the deletions and inserts with the recipe being an argument passed to it as the persistence layer as inserts and deletions are something that occur to your cookbook not your recipe.
-- Regards
John Timney ASP.NET MVP Microsoft Regional Director
-- Regards
John Timney ASP.NET MVP Microsoft Regional Director
".net lear" <asdfasdf> wrote in message news:uu*************@TK2MSFTNGP12.phx.gbl... > if I have an object, say a recipe, which is added to a database, whose > responsibility is it to add to the db? The recipe or something else? > > Let's say I want to delete a recipe? Does the recipe kill itself? Or > does > the database or something else do the removal? > > Where does the responsibility lie? > > Thanks. > > >
thanks a lot.
"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message
news:Ol****************@TK2MSFTNGP09.phx.gbl... How it inherits depends on your encapsulation, and whether there is any interaction between the cookbook and the recipe. In an ideal OO scanrio
the recipe should be self contained, telling you only how to make the dish.
The cookbook knows nothing about making the dish, thus it needs to inherit
none of the properties of the recipe to function as a cookbook - it only needs
to contain recipe objects, like a namespace containing lots of different classes. The classes in the namespace can be interelated by existing in
the namespace, but need not know anything about each other unless thats how to need the objects to interact. Connected to this, the way you serve the recipe (the presentation (layer)) has nothing to do with how it is stored
in the cookbook (persistence (layer)) or how it is cooked (business (layer))
Mutli tiered or layered implementations perform different and self
contained elements of your programming logic, like your presentation layer knowing about plates and cress but nothing about cooking times. Theres a very
nice and straingtforward explanation of multi tiered applications here that
might be worth taking a look at.
http://www.dfpug.de/konf/konf_1999/g...ier/e_tier.htm
-- Regards
John Timney ASP.NET MVP Microsoft Regional Director
".net lear" <ms*********@gmail.com> wrote in message news:11**********************@g47g2000cwa.googlegr oups.com... Thanks a lot.
I'm just getting started with this concept, very used to procedural programming.
Isn't the cookbook just a collection of recipes? In other words, doesn't it inherit from recipe to some degree?
When you say "stored in the cookbook (persistence or data layer)", can you elaborate? What does that mean?
John Timney (ASP.NET MVP) wrote: The recipe only tells you how to cook the dish, it has no concept of where the recipe is stored in your kitchen. As it happens its stored in the cookbook (the persistence or data layer). storing the recipe has
nothing to do with cooking the dish, so you should refrain from including that
logic in your business layer (the recipe) - ideally the cookbook would do the deletions and inserts with the recipe being an argument passed to it as the persistence layer as inserts and deletions are something that occur to your cookbook not your recipe.
-- Regards
John Timney ASP.NET MVP Microsoft Regional Director
-- Regards
John Timney ASP.NET MVP Microsoft Regional Director
".net lear" <asdfasdf> wrote in message news:uu*************@TK2MSFTNGP12.phx.gbl... > if I have an object, say a recipe, which is added to a database,
whose > responsibility is it to add to the db? The recipe or something else? > > Let's say I want to delete a recipe? Does the recipe kill itself? Or > does > the database or something else do the removal? > > Where does the responsibility lie? > > Thanks. > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Richard B. Kreckel |
last post by:
Hi!
I was recently asked what book to recommend for a beginner in C++. I
am convinced that you needn't study C in depth before learning C++
(though it helps), but cannot find any beginner's...
|
by: Grrrbau |
last post by:
I'm a beginner.
I'm looking for a good C++ book.
Someone told me about Lafore's "Object-Oriented Programming in C++".
What do you think?
Grrrbau
|
by: Rensjuh |
last post by:
Hello, does someone have / know a good C++ tutorial for beginnners? I would prefer Dutch, but English is also fine.
Hoi, heeft / kent iemand nog een goede C++ tutorial voor beginners? Het liefste...
|
by: MHoffman |
last post by:
I am just learning to program, and hoping someone can help
me with the following:
for a simple calculator, a string is entered into a text
box ... how do I prevent the user from entering a text...
|
by: mitchellpal |
last post by:
Hi guys, am learning c as a beginner language and am finding it rough
especially with pointers and data files. What do you think, am i being
too pessimistic or thats how it happens for a beginner?...
| |
by: weight gain 2000 |
last post by:
Hello all!
I'm looking for a very good book for an absolute beginner on
VB.net or VB 2005 with emphasis on databases. What would you
reccommend?
Thanks!
|
by: macca |
last post by:
Hi, I'm looking for a good book on PHP design patterns for a OOP
beginner - Reccommendations please?
Thanks
Paul
|
by: Roman Zeilinger |
last post by:
Hi
I have a beginner question concerning fscanf.
First I had a text file which just contained some
hex numbers:
0C100012
0C100012
....
|
by: hamza612 |
last post by:
I want to start learning how to program. But I dont know where to
start. From what I've heard so far c++ is not a good lang. to learn
as a beginner because its very complicated compared to others...
|
by: ddg_linux |
last post by:
I have been reading about and doing a lot of php code examples from
books but now I find myself wanting to do something practical with
some of the skills that I have learned.
I am a beginner php...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |