473,756 Members | 3,051 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Objects, objects, so many objects! ;-)

Hi all,

I have a very general but quite significant question about objects.

My question is, when should I create them? I know thats a crap question so
let me explain a bit further.

Lets take an example of user management against a database. Things I might
like to do include:

- Creating a new user
- Changing a users phone number
- Deleting a user
- Getting a users age
- Updating a users password

The thing with all this is not one of those operations require the
instantiation of a User object. You could do it through static methods.

The thing is, you the sort of operations above must make up 80% or so of all
operations on users. Likewise, operations similar to these ones effect most
business entities, be it a Bug or a Role or a Car object.

So my question is - is it really the case, that a good proportion of the
time, you dont need to instantiate an object at all to achieve your aims, or
am I using a poor approach to design my applications?

Many thanks to anyone who can share some advice.

Kindest Regards

tce
Jul 21 '05
11 1792
Hello TCE,

There is one more thought that I haven't seen mentioned among your
responses. I consider this to be the most important reason for using
objects to represent structures that encapsulate an idea...

Communication

Very very few projects anymore can be completed, in a reasonable timeline,
with only one person working on it. We work in teams, often sizeable teams.
We need to communicate very efficiently. To do that, we've invented
literally thousands of concepts and terms, all of which help this along.

If I use the phrase "processor bound" to refer to an algorithm, you would
(hopefully) think that I am talking about an application where the limiting
factor on performance is the speed and availability of CPU cycles, as
opposed to memory, hard disk space, bus speed, port speed, etc. Similarly,
if I use the term "Data Access Layer," you can think of a "group" of classes
or code within an application that handles the impedence between the
relational storage mechanism of our databases and the hierarchical
representation typically used in application memory.

Common terms allow us to communicate at a higher level, to share ideas
effectively, and to get to the point.

Object Oriented programming is not about objects. Those are simply the
shape of the tools. OOP is about communicating at a higher level by
creating a concept surrounding an implementation, and encapsulating the
implementation within a set of objects.

The simple form of this idea is obvious: objects that represent "things."
However, we have moved up from there, to create a series of expressions that
describe how we can create sets of objects that work together. These
expressions are called design patterns, and they have names.

A design pattern is not an algorithm. It is not like a finely tuned bubble
sort or a special way to handle collections. It is a description of how
"design" problems present themselves and how they can be solved in a
managable and maintainable manner using objects. You don't share snippets
of code, except as examples. You share the idea, the concept, and the name
that is attached to it.

These terms are added to the lexicon. Just like we use "Data Access Layer"
to describe a solution within an applications program structure, we can use
names like "Strategy pattern," "Abstract Factory," and "Chain of
Responsibility" to refer to constructs that allow us to solve design
problems.

It takes years to learn to use these terms effectively. There is an entire
series of books dedicated to describing standard patterns (far beyond those
described by Microsoft in their Patterns and Practices literature, which is
mostly a tiny set of implementation-specific patterns). The books are so
widely used that they are referred to by abbreviated terms.

The grand-daddy of the patterns books is called "Design Patterns: Elements
of Reusable Object Oriented Software" by Gamma, Helm, Johnson, and
Vlissides. The authors are referred to as the "Gang of Four" so you will
hear the book cited as merely [GoF]. It is a difficult book to read, but it
started a landslide. Other books from Buschmann, Fowler, and others have
followed. I referred to one of these books: "Design Patterns Explained" by
Shalloway and Trott, in an earlier reply to one of your postings.

In fact, just for you, I created a list of some of these books on Amazon.
http://www.amazon.com/exec/obidos/tg...848276-2065456

It is not possible, in a newsgroup posting, to describe an entire practice
of software development. I hope only to have awakened your curiosity.

At the end of the day, it's the ability to communicate at this higher level
that makes it worthwhile to use OO design. In other words, in programming,
as in life, it's all about the people.

Hope this helps,
--- Nick

"thechaosengine " <sh856531@micro softs_free_emai l_service.com> wrote in
message news:ua******** ******@tk2msftn gp13.phx.gbl...
Hi everyone,

Thanks for you're advice.

Well, everyone seems quite entrenched in the idea that making objects to do stuff is good. Which is as I expected.

I still don't see WHY I would make an object to do stuff when there is no
real need. Someone mentioned that it's to hold business rules - but static
methods can hold these rules just as easily as an instance.

I'm not at all worried about the performance cost of making objects, its
just in a great many situations (and in a great many sample applications)
there doesnt seem to be much call for making an object to perfrom an action.
In the applications that I'm playing with at the moment, the only time I
actually create individual objects is when dealing with collections of
entities - where making an in memory representation has real benefits. For
other things, like making an update to a database, there just doesnt seem
much point. Bearing in mind that I'm making web applications here - a lot of the time I don't want in memory collections of lots of objects - I just
don't seem to need them.

Thanks for your comments so far

Kindest Regards

tce

Jul 21 '05 #11
Can you be more specific and clear?

with regards,
J.V.Ravichandra n
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandra n+J.V.&cob=aspn etpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID= P3966388&BN=999 &PN=2
- Or, just search on "J.V.Ravichandr an"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8254
by: dasod | last post by:
I would like to know if my method to remove list objects is correct in this small test program. It seems to me that there might be a simplier way, but I'm afraid I don't know enough about list iterators and how they are behaving in situations like this. #include <iostream> #include <list> class Test; typedef std::list< Test* > Tlist;
9
1889
by: Aguilar, James | last post by:
Hey guys. A new question: I want to use an STL libarary to hold a bunch of objects I create. Actually, it will hold references to the objects, but that's beside the point, for the most part. Here's the question: I want to be able to change the references (including deleting them). Is there any way to do that besides using pointers rather than references for the STL library? I'd also prefer to avoid using const_cast, if it is indeed...
6
2577
by: Alfonso Morra | last post by:
I have written the following code, to test the concept of storing objects in a vector. I encounter two run time errors: 1). myClass gets destructed when pushed onto the vector 2). Prog throws a "SEGV" when run (presumably - attempt to delete deleted memory. Please take a look and see if you can notice any mistakes I'm making. Basically, I want to store classes of my objects in a vector. I also have three further questions:
3
3032
by: ytrewq | last post by:
Should dynamic ("expando") properties be restricted to native and user-defined objects? Or should host objects - such as references to the browser or a plug-in or to the document and its elements - also allow them? Adding (and removing) object properties dynamically is an acceptable and common practice in JavaScript, and greatly adds to the power and character of the language. Essentially, an object in JavaScript can be considered to...
8
1863
by: Lüpher Cypher | last post by:
Hi, Suppose we have a hierarchical class structure that looks something like this: Object | +-- Main | +-- Object1
161
7866
by: KraftDiner | last post by:
I was under the assumption that everything in python was a refrence... so if I code this: lst = for i in lst: if i==2: i = 4 print lst I though the contents of lst would be modified.. (After reading that
7
8223
by: Jo | last post by:
Hi, How can i differentiate between static and dynamic allocated objects? For example: void SomeFunction1() { CObject *objectp = new CObject; CObject object;
21
2212
by: George Exarchakos | last post by:
Hi everyone, I'd like your help... Can we have a std::list<BASEwhere BASE be the base class of a class hierarchy? I want to add to this list objects that are inherited from BASE class but not necessarily the same... class base { int x;
27
2567
by: SasQ | last post by:
Hello. I wonder if literal constants are objects, or they're only "naked" values not contained in any object? I have read that literal constants may not to be allocated by the compiler. If the Standard is saying that "object is a region of storage", I deduce from that that literal constants aren't objects because they may not be alocated as regions of storage in the memory.
14
6023
by: Jess | last post by:
Hello, I learned that there are five kinds of static objects, namely 1. global objects 2. object defined in namespace scope 3. object declared static instead classes 4. objects declared static inside functions (i.e. local static objects) 5. objects declared at file scope.
0
9273
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10032
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9872
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9841
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7244
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5141
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5303
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
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 we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.