473,583 Members | 3,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Classes as concepts.

I had read that you should use classes to represent concepts. How does
this work and what kind of concepts should be reresented as classes.

Jul 23 '05 #1
6 1393
enki wrote:
I had read that you should use classes to represent concepts. How does
this work and what kind of concepts should be reresented as classes.


I think you're in a wrong newsgroup. Please try 'comp.object' or a good
OOD (Object-Oriented Design) book.

V
Jul 23 '05 #2
enki wrote:
I had read that you should use classes to represent concepts. How does
this work and what kind of concepts should be reresented as classes.


That verbiage is a cheap way to inspire you to think in terms of objects. It
can mislead.

Some folks say "read your requirements, and pull out the important-sounding
nouns". So even hallow this "search for nouns" as a phase in designing.

So suppose I find the noun "Car". That sounds like a harmless, obvious
candidate for a class, right?

It depends on the application. I could be writing a simulator for a
wind-tunnel to find a good shape for a car. I could be writing the
controller for a car's engine. I could be writing the point-of-sale software
for a carwash.

In each case, the Car itself is nebulous. Wind-tunnel software needs to
model shapes whose actual car-ness is irrelevant. The car's engine's
controller has only one car object, so its attributes can safely disperse
thru the controller. Nobody should ever decouple the controller from the
engine and plug it into a different car with different attributes. And
carwash software needs to track a carwash _event_, from buying a ticket to
entering the carwash with the ticket.

Ultimately, we need objects that present clean useful interfaces, so their
client modules can use them in straightforward ways. So suppose a carwash
user buys a ticket at a gas pump, then types their ticket number into the
carwash user interface, requesting permission to drive in. That leads to
this:

usersNumber = getUserNumberFr omUI()
ticket = database.getTic ket(usersNumber )

if ( ticket and
ticket.day == today and
not ticket.isWashed Yet() and
ticket.isCredit Checked() ) then
UIdisplay("PLEA SE ENTER CARWASH")
ticket.isWashed Yet(true)
return true
else
UIdisplay("WRON G NUMBER. TRY AGAIN")
return false
end

This "analysis" has not revealed a Car object yet, despite the fact that
cars are a critical component of every carwash, anywhere. It reveals the
Ticket is the determinant object, and its behavior changes with its state.
After a wash event, you can't drive around and use your ticket again.

Objects are bags of behavior. Partitioning that behavior among objects helps
us invent objects that are easy to use right and hard to use wrong. The
search for nouns will help, but ultimately behaviors drive design. After
putting related behaviors together into an object, _then_ you think of a
name for that object's concept.

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
Jul 23 '05 #3
On 8 Jul 2005 12:45:20 -0700 in comp.lang.c++, "enki"
<en*****@yahoo. com> wrote,
I had read that you should use classes to represent concepts. How does
this work and what kind of concepts should be reresented as classes.


Read the 1972 paper by David Parnas "On the criteria to be used in
decomposing systems into modules".
PDF at http://doi.acm.org/10.1145/361598.361623

Everywhere that Parnas writes "module", you substitute "class".

Jul 23 '05 #4
Victor Bazarov wrote:
enki wrote:
I had read that you should use classes to represent concepts. How does
this work and what kind of concepts should be reresented as classes.


I think you're in a wrong newsgroup. Please try 'comp.object' or a good
OOD (Object-Oriented Design) book.


Maybe it's you who is in the wrong newsgroup. Concepts play an
important role in STL:
http://www.sgi.com/tech/stl/stl_introduction.html

Jul 23 '05 #5
"Phlip" <ph*******@yaho o.com> wrote in message
news:4b******** ********@newssv r31.news.prodig y.com...
This "analysis" has not revealed a Car object yet, despite the fact that
cars are a critical component of every carwash, anywhere. It reveals the
Ticket is the determinant object, and its behavior changes with its state.
After a wash event, you can't drive around and use your ticket again.


Further analysis ....

Use Case 100: Oh $%&%^&* it scratched the car!!

What should we do?

Carwash SME: Well we'd need to record the car details as part of our
diagnosis of the fault.

May need a new Value Object ..... we could call it Car ... we could call it
Vehicle ... we could call it ObjectInTheCarW ash ... I'd probably start with
Car

:-)

Shane

--
" We should turn our attention back to pleasing our customer. That's what
keeps the paychecks rolling in." -- Ron Jeffries

Jul 23 '05 #6
Shane Mingins wrote:
Use Case 100: Oh $%&%^&* it scratched the car!!

What should we do?

Carwash SME: Well we'd need to record the car details as part of our
diagnosis of the fault.

May need a new Value Object ..... we could call it Car ... we could call it Vehicle ... we could call it ObjectInTheCarW ash ... I'd probably start with Car


class Scratch {
string make;
string model;
string year;
string vin;
string location;
}

Okay. Now push that into a database and normalize it, and you have a Car
table. Maybe...

--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand
Jul 23 '05 #7

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

Similar topics

7
2267
by: Bora | last post by:
I usually find that a number of unrelated classes require the same kind of operations. However, I don't want to duplicate code in multiple places. In Java, I've seen those "Utility Classes", which are basically static (singleton) classes created to encapsulate related operations in one class. These methods can be called from other classes...
24
2544
by: Alf P. Steinbach | last post by:
The eighth chapter (chapter 2.1) of my attempted Correct C++ tutorial is now available, although for now only in Word format -- comments welcome! Use the free & system-independent Open Office if you don't have Word. Classes <url: http://home.no.net/dubjai/win32cpptut/w32cpptut_02_01.zip> Introduces the C++ language feature used to...
2
3031
by: Indiana Epilepsy and Child Neurology | last post by:
Before asking this questions I've spent literally _years_ reading (Meyer, Stroustrup, Holub), googling, asking more general design questions, and just plain thinking about it. I am truly unable to figure out what would be a "proper" OO design (in C++) for this. There may be alternatives to writing my own ODBC handle classes, and I may be...
132
4786
by: Kevin Spencer | last post by:
About 2 years ago, and as recently as perhaps 1 year ago, I can recall seeing many posts about what language to use with ASP.Net. The consensus was that employers paid more for C# programmers, and it seems that C# became the darling of the ASP.Net crowd. In the meantime, I have observed an interesting phenomenon. Originally, employers hired...
4
2118
by: Chris F Clark | last post by:
Please excuse the length of this post, I am unfortunately long-winded, and don't know how to make my postings more brief. I have a C++ class library (and application generator, called Yacc++(r) and the Language Objects Library) that I have converted over to C#. It works okay. However, in the C# version, one has to build the class library...
31
1724
by: attique63 | last post by:
how could I write a program that will declare a class point. The class point has two private data members x and y of type float. The class point has a parameterized constructor to initialize both the data members i.e. x and y. The class point has a member function display() that display the value of x and y. Create two objects p1 and p2 with...
18
1886
by: Tom Cole | last post by:
I'm working on a small Ajax request library to simplify some tasks that I will be taking on shortly. For the most part everything works fine, however I seem to have some issues when running two requests at the same time. The first one stops execution as the second continues. If I place either an alert between the two requests or run the second...
1
1293
by: darrel | last post by:
Can anyone recommend a course/class/training event that focuses on OOP concepts in the context of ASP.net? My background: My education is in art/graphic design. Later spending most of my time doing web design (IA, html, css, javascript, etc.) For the past 4 years or so I've been doing less graphic design and a lot more ASP.net web...
1
2116
by: Swathika | last post by:
Hi, Sometimes, you never get chance to learn 'Advanced Design Concepts and Real-time Scenarios' from institutes or through book-learning. But, in my blog, I have gathered some of the amazing Design concepts and practical scenarios in J2EE. Design Concepts:...
0
8176
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. ...
0
8321
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...
0
8191
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6578
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5699
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...
0
5370
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3841
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1426
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1154
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.