New topic: 

OOP, a simple Class ( Inheritance )

<http://forums.realsoftware.com/viewtopic.php?t=45207>

         Page 1 of 2
   [ 17 posts ]   Go to page 1, 2  Next                Previous topic | Next 
topic          Author  Message        TomazVDaSilva          Post subject: OOP, 
a simple Class ( Inheritance )Posted: Sat Sep 01, 2012 11:32 am                 
                
Joined: Thu Dec 29, 2011 6:46 pm
Posts: 168
Location: Edmonton, AB, Canada                Hi friends,
I have been studying UML and and it seems to me that a project should start 
from at least a Class Diagram.
To me all those diagrams ( activity, class, association, sequence, component 
and others ) helps a lot the developer to have a clear and global view of the 
project without loosing the understanding of its parts. I never programmed OOP 
before so all these strategies seems great to me.

Any way, I found a RB development in the internet called simpleDraw, I tried to 
understand what the creator did but RB structure still seems confuse to me. I 
am used to see all the code in a page as in VB, not the "Sub"in a TextField and 
no "End Sub" at all, and then the declaration and properties hanging on the 
control pane Tree View, etc.Probably with more practice I will be adapted to RB.

I took what was done and put into diagrams to facilitate my understanding, I do 
not have a UML software so I did manually using MS Excel.
Download SimpleDraw from : http://www.applelinks.com/rbu/085/simpledraw.sit

This just my diagram...


However I am still having problems to create class involving Canvas, Graphics 
and Paint.
It would be nice if we have books for beginner on OOP specific for RB.      
_________________
Regards,
TomazVDaSilva

Clean Code: Robert C. Martin
It is not the language that makes programs appear simple. 
It is the programmer that make the language appear simple!  
                             Top                charonn0          Post subject: 
Re: OOP, a simple Class ( Inheritance )Posted: Sat Sep 01, 2012 1:44 pm         
                        
Joined: Mon Apr 02, 2007 2:08 am
Posts: 893
Location: San Francisco, CA, USA                (wasn't able to look at the 
project file as I don't have Stuffit.)

TomazVDaSilva wrote:It would be nice if we have books for beginner on OOP 
specific for RB.

Chapter 10 of the REALstudio Users Guide covers classes and OOP. Class 
inheritance is discussed in the Understanding Subclasses subsection      
_________________
Boredom Software  
                             Top                DaveS          Post subject: 
Re: OOP, a simple Class ( Inheritance )Posted: Sat Sep 01, 2012 2:38 pm         
                        
Joined: Sun Aug 05, 2007 10:46 am
Posts: 4067
Location: San Diego, CA                First off.  Canvas IS a class....
Graphics is a property of that Class
and Paint is an EVENT of that class

When the Paint Event is fired (via a coded refresh, or by system events (a 
window moving etc)).  the code in that event is executed.... the purpose of 
which is to refresh the GRAPHICS property.

All activities that draw on the GRAPHICS property of a CANVAS should always be 
controlled by the PAINT event. You should not attempt to draw directly to the 
GRAPHICS object without going thru this event.

So... in your example.... You could/would subclass a CANVAS and add methods for 
CIRCLE, SQUARE etc.... but they again would have to be dependant on the PAINT 
event and accept the graphics object ONLY as a passed argument from the CANVAS.


Personally I HATE UML....... (and I've been in this business 35 years). To me 
UML describes a process to business users.... but NOT to a particular OOP 
implementation (my opinion)      
_________________
Dave Sisemore
MacPro, OSX 10.7.3 RB2011r3
Note : I am not  interested in any solutions that involve custom Plug-ins of 
any kind  
                             Top                TomazVDaSilva          Post 
subject: Re: OOP, a simple Class ( Inheritance )Posted: Sat Sep 01, 2012 4:56 
pm                                 
Joined: Thu Dec 29, 2011 6:46 pm
Posts: 168
Location: Edmonton, AB, Canada                charonn0 wrote:(wasn't able to 
look at the project file as I don't have Stuffit.)

Here is the .rb file so you can see it : 
http://www.mediafire.com/download.php?z2p4u1y7izn73bk      
_________________
Regards,
TomazVDaSilva

Clean Code: Robert C. Martin
It is not the language that makes programs appear simple. 
It is the programmer that make the language appear simple!  
                             Top                TomazVDaSilva          Post 
subject: Re: OOP, a simple Class ( Inheritance )Posted: Sat Sep 01, 2012 5:32 
pm                                 
Joined: Thu Dec 29, 2011 6:46 pm
Posts: 168
Location: Edmonton, AB, Canada                DaveS,

Thank for your reply.
I appreciate your explanation on Class/Property/Event.

Well, I am not a "professional" programmer as many of the people in this forum.

I bought few dozen books, and some of them on the subject of UML and OOP.
Yes, there are many diagrams to learn:

See "THE OBJECT ORIENTED PRIMER", page 29 by Scott W. Ambler
1) Activity
2) Class
3) Communication
4) Component
5) Composite Structure
6) Deployment 
7) Interaction Overview
8.) Object
9) Package
10) Sequence
11) State Machine
12) Timing
13) Use Case

I am investing a portion of my time to learn the concepts, before start really 
programming RB.
Unfortunately the "REALbasic: The definitive Guide" do not teach the basics of 
programming.

I bought 2 other books that diverge a little on the paradigm of OOP.

1) (TAD) Tabular Application Development for Information Systems by Talib Damij
  it seems very nice and iteresting working with matrices of Activities versus 
Entities.

2) (OPM) Object Process Methodology by Dov Dori
  I was able to contact Dr, Dov Dori and he was very kind sending me even some 
of his papers.
  The good thing about OPM is that it has in one diagram only all the nuances 
of the UML method.
  But at this point I still few necessity to learn the standard UML as in the 
http://uml.org/

I particularly like and prefer start my thinking process deductively, meaning 
start with a global idea of the development then break it down in parts. Just 
like a WBS (work breakdown structure) in project management.

In addition I have also VB 6.0 step-by-step by Michael Halvorson that I bought 
many years ago to learn VBA.
He divides the development in 3 easy parts:
  1) Create your interfaces first
  2) Define the attributes
  3) Put in the code 

I had use this 3 steps for MS-Excel VBA.

Said that I ask.
DaveS, what do you use as method to develop your applications ?

Best Regards, Tomaz      
_________________
Regards,
TomazVDaSilva

Clean Code: Robert C. Martin
It is not the language that makes programs appear simple. 
It is the programmer that make the language appear simple!  
                             Top                charonn0          Post subject: 
Re: OOP, a simple Class ( Inheritance )Posted: Sat Sep 01, 2012 5:33 pm         
                        
Joined: Mon Apr 02, 2007 2:08 am
Posts: 893
Location: San Francisco, CA, USA                Say you had three classes, 
MySuper, MySub, and MyOtherSub:

Class MySuper
  Sub Draw()
  DrawArea.DrawString("You can override this method!", 10, 10)
  End Sub
  
  Property DrawArea As Graphics
  End Class
Class MySub
Inherits MySuper
  Sub Draw()
  //Overrides the Draw method from MySuper
  DrawArea.DrawString("Hello, world!", 10, 10)
  End Sub
End Class
Class MyOtherSub
Inherits MySuper
  Sub Draw()
  //Overrides the Draw method from MySuper
  DrawArea.DrawString("Goodbye, world!", 10, 10)
  End Sub
End Class


The class MySuper has one method (Draw) and one property (DrawArea As 
Graphics.) The MySub and MyOtherSub classes inherit the method and the property 
from MySuper, but override MySuper's Draw method with their own. 

In this way, multiple classes with similar, but unique, functions can all be 
based on a single superclass that provides all the common bits while each 
subclass adds its unique bits or overrides the parent's bits. This saves code 
duplication and allows you to treat subclasses of MySuper in a uniform manner:
Dim MyMessage As New MySuper
Dim MyGreeter As New MySub
Dim MyFarewell As New MyOtherSub

MyMessage.Draw  //Calls the original Draw method
MyGreeter.Draw  //Calls the MySub.Draw override method
MyFarewell.Draw //Calls the MyOtherSub.Draw override method


Neither subclass has a DrawArea property defined so they use the non-overridden 
DrawArea property from the MySuper.      
_________________
Boredom Software  
                             Top                wbgookin          Post subject: 
Re: OOP, a simple Class ( Inheritance )Posted: Sat Sep 01, 2012 6:15 pm         
                
Joined: Sat Aug 22, 2009 9:44 am
Posts: 287                TomazVDaSilva wrote:It would be nice if we have books 
for beginner on OOP specific for RB.

Check out the one from Relevant Logic, it's a little old I think, but uses RB:
http://relevantlogic.com/oop-book/about-the-oop-book.php   
                             Top                timhare          Post subject: 
Re: OOP, a simple Class ( Inheritance )Posted: Sat Sep 01, 2012 6:22 pm         
                
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 11633
Location: Portland, OR  USA                Quote:See "THE OBJECT ORIENTED 
PRIMER", page 29 by Scott W. Ambler
1) Activity
2) Class
3) Communication
4) Component
5) Composite Structure
6) Deployment 
7) Interaction Overview
8.) Object
9) Package
10) Sequence
11) State Machine
12) Timing
13) Use Case
Since you are not a "professional" programmer, I'd recommend you put the book 
down and forget all that stuff.  It falls more into the academic than 
practical.  It will just get in the way of you learning to program.  Go look at 
RB-specific books like Guyren Howe's.   
                             Top                TomazVDaSilva          Post 
subject: Re: OOP, a simple Class ( Inheritance )Posted: Sat Sep 01, 2012 7:12 
pm                                 
Joined: Thu Dec 29, 2011 6:46 pm
Posts: 168
Location: Edmonton, AB, Canada                wbgookin wrote:TomazVDaSilva 
wrote:It would be nice if we have books for beginner on OOP specific for RB.

Check out the one from Relevant Logic, it's a little old I think, but uses RB:
http://relevantlogic.com/oop-book/about-the-oop-book.php


I bought this book few months ago, have you seen the book ?
Real OOP with REALbasic
by Guyren G Howe

I did received the book in PDF format, protected, encrypted and with my name in 
each page of the book.
A silly attempt by the author to keep a buyer from distribute the book freely.


Well, the book has 148 pages...  
the Introduction of the book  is page 10 and half of page 11.
Goals , Assumptions, How to Use this book
Quote:The goal of this book is to teach you the basics of Object Oriented
Programming (OOP) using REALbasic. This means that this book
should help you to understand when and why object oriented
techniques should be applied in program design, and to create simple
object oriented designs of your own. You should also be better able
to read OOP advice and code, mostly understand it, and generally be
off to a good start with becoming an effective OOP designer.

The word encapsulation appears only 3 times in the book: 
And no explanation or example of what is encapsulation.

First on page 61: 
Quote:It defines a collection of similar things—it acts as a template for
stamping out instances of the class, which are bundles of the
class’s properties in the computer’s memory that you can access
from the methods in the class (this bundling of properties
accessible by the class’s methods is called encapsulation);

Second on page 62:
Quote:Encapsulation
Note that the class holds the code that is able to manipulate any of
those bundles of properties. Whenever that code accesses a property
of the class, the values accessed are automatically those in the
bundle of properties referred to by the variable you are using. So
when you do:
Dim x As New SomeClass
x.SomeMethod

Third on page 140
Quote:The advantage of the latter approach is that encapsulation is better
(the code for what each control does is inside the control). If you
need to reset the controls in multiple places, the code will be simpler,
and if you add new types of controls that you’ll need to reset, rather
than having to search for everywhere you reset controls and add that
case, you just need to add the Class Interface to your new class, and
you’re fine.

Friends, sorry... but I have to disagree.
The book do not attempt to fulfill its goal described in the its own 
introduction.
Anyone that has no knowledge on OOP will not learn it from the book "REAL OOP 
with REALbasic".      
_________________
Regards,
TomazVDaSilva

Clean Code: Robert C. Martin
It is not the language that makes programs appear simple. 
It is the programmer that make the language appear simple!  
                             Top                timhare          Post subject: 
Re: OOP, a simple Class ( Inheritance )Posted: Sat Sep 01, 2012 8:05 pm         
                
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 11633
Location: Portland, OR  USA                It seems to define very well what 
encapsulation is
Quote:the code for what each control does is inside the control
There's not much more to say, other than encapsulation means to hide the 
details inside the class.  The outside world should interact with the public 
methods and properties and not depend on the actual details of the code.

Don't make OOP more complex than it is, like the academics love to do.   
                             Top                TomazVDaSilva          Post 
subject: Re: OOP, a simple Class ( Inheritance )Posted: Sat Sep 01, 2012 9:09 
pm                                 
Joined: Thu Dec 29, 2011 6:46 pm
Posts: 168
Location: Edmonton, AB, Canada                timhare,

I was talking about the didactic of the book on teaching OOP for REALbasic.  
I was not talking about the consistence or adequacy of encapsulation definition.

I do have the book and my assessment of the book is that it doesn't do a good 
job.

1) I would like to see a clear definition of the concept.
2) An abstraction of a real world object.
3) A class diagram of that abstraction.
4) A step-by-step how to create that class in RB.
5) An application in RB using that Class.

I have bought as well the virtual training on OOP for JAVA and C++ which I have 
finished already.
All the training is based on the definition followed by practical examples, and 
interviews with Bjarne Stroustrup the creator of C++. BTW I read his book as 
well "What is Object-Oriented programming"

So far the best didactic on RB which I had contact with is:
REALbasic University Archives: http://www.applelinks.com/rbu/archive.shtml
It has 110 lessons written by Marc Zeedar (http://www.zeedar.com/index.html).   
   
_________________
Regards,
TomazVDaSilva

Clean Code: Robert C. Martin
It is not the language that makes programs appear simple. 
It is the programmer that make the language appear simple!  
                             Top                npalardy          Post subject: 
Re: OOP, a simple Class ( Inheritance )Posted: Sat Sep 01, 2012 11:17 pm        
               Real Software Engineer          
Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7399
Location: Canada, Alberta, Near Red Deer                You could also check 
http://docs.realsoftware.com/index.php/ ... Curriculum      
_________________
My web site Great White Software
RBLibrary.com REALbasic learning  
                             Top                gisborne          Post subject: 
Re: OOP, a simple Class ( Inheritance )Posted: Sat Sep 01, 2012 11:55 pm        
                 
Joined: Tue Feb 06, 2007 11:34 pm
Posts: 167
Location: Austin, TX                I'm the author of  the REALbasic OOP book.

I'll see about adding a definition of encapsulation when I get a chance to 
revise the book. Thanks for pointing that out.

I'm sorry that you didn't find the book adequate to your needs. If you'd drop 
me a note about what you thought were its insufficiencies, I'll see what I can 
do about addressing them in a revision also. If you really feel that I didn't 
give you what I promised, I'd be happy to refund your purchase.

I'm not trying to defend myself, but I would just note that OOP is a large and 
complex topic. One could study it for years. My aim in the book was just to get 
a REALbasic user over the main conceptual hurdles that one encounters when 
learning OOP. The most important being, in general, what polymorphism is and 
how it is useful in programming. If I got you to understand that, I'll have 
achieved my major goal. I'm hoping I at least got you a bit closer a bit 
quicker.

I guess my other major goal was to replace the execrable discussion of the 
topic in the REAL documentation. The section on Events, in particular, bordered 
on being flat-out wrong. It's a while since I looked at the REAL docs on the 
topic, however; they may have gotten better.

I'm sure the book could be improved considerably, and I would love to hear what 
you feel are the major issues. It would be most helpful if you'd send me a 
quick note about what you felt were the major issues, offline.      
_________________
Read my book, Real OOP with REALbasic
Guyren G Howe
Relevant Logic LLC

guyren-at-relevantlogic.com ~ http://relevantlogic.com

REALbasic, PHP, Ruby/Rails, Python programming
PostgreSQL, MySQL database design and consulting
Technical writing and training  
                             Top                TomazVDaSilva          Post 
subject: Re: OOP, a simple Class ( Inheritance )Posted: Sun Sep 02, 2012 11:08 
am                                 
Joined: Thu Dec 29, 2011 6:46 pm
Posts: 168
Location: Edmonton, AB, Canada                Mr. Howe

I Thank you for your feedback on my comments regarding the book.
I would be more than glad to discuss in details the aspects of the book from my 
point of view,
And listen from you on the subject.

If so, I will do it offline as you requested, anyway this discussion is a 
little out of the topic, and we should take it outside.      
_________________
Regards,
TomazVDaSilva

Clean Code: Robert C. Martin
It is not the language that makes programs appear simple. 
It is the programmer that make the language appear simple!  
                             Top                TomazVDaSilva          Post 
subject: Re: OOP, a simple Class ( Inheritance )Posted: Sun Sep 02, 2012 11:09 
am                                 
Joined: Thu Dec 29, 2011 6:46 pm
Posts: 168
Location: Edmonton, AB, Canada                npalardy wrote:You could also 
check 
http://docs.realsoftware.com/index.php/ ... Curriculum

Thank you !, I will take a look.      
_________________
Regards,
TomazVDaSilva

Clean Code: Robert C. Martin
It is not the language that makes programs appear simple. 
It is the programmer that make the language appear simple!  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 2
   [ 17 posts ]   Go to page 1, 2  Next     
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to