|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome. |
Share Thread: & Tags
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
1. Introduction.
By using the JavaScript Create Object, you can get a soft introduction to object oriented programming (OOP). The resources at W3Schools, where you can learn the basics of nearly all web design are excellent. It has an inbuilt editor where you can modify example code and see the effect immediately. 2. Start. http://www.w3schools.com/js/js_objects.asp Read that section and click on the examples (takes 5 to 10 minutes). - Create a direct instance of an object. - Create a template for an object. In the last example modify the code in the left window to: (Modifications in bold) <html> <body> <script type="text/javascript"> function person(firstname,lastname,age,eyecolor) { this.firstname=firstname this.lastname=lastname this.age=age this.eyecolor=eyecolor this.newfirstname=newfirstname } function newfirstname(new_firstname) { this.firstname=new_firstname } myFather=new person("John","Doe",50,"blue") myFather.newfirstname("James") document.write(myFather.firstname + " is " + myFather.age + " years old.") </script> </body> </html> and click the button "Edit the text and click me". Note the difference. 3. Exercise. Write a function that changes the persons age, set the new age to 60 and submit the change. Now you have a vague idea of OOP. 4. Next step. Download free the first three chapters of the book "The PHP Antohology: Object Oriented PHP Solutions , Volume 1." by Harry Fuecks from SitePoint. http://www.sitepoint.com/books/phpant1/ Chapter 2. Object Oriented PHP explains how you may make your own page object. Then you can add the properties and layout you want to that object and make your own page templates, eg. a table with three tables for header, body and footer with different properties etc. Once you understand OOP, you will love it. Also start your first step on Extreme Programming XP, by writing the tests of your code before anything else: Exapmle: Again we use the resources at W3schools: http://www.w3schools.com/js/js_onerror.asp Use the code in "The onerror event" example to write a test to test for JS errors on the page. Copy this code: <script type="text/javascript"> onerror=handleErr var txt="" function handleErr(msg,url,l) { txt="There was an error on this page.\n\n" txt+="Error: " + msg + "\n" txt+="URL: " + url + "\n" txt+="Line: " + l + "\n\n" txt+="Click OK to continue.\n\n" alert(txt) return true } function message() { alert("JS code is OK!") } </script> in the head section and this code in the body section before your own code: Write this code in the body section: <input type="button" value="View message" onclick="message()" /> You may improve the test by using JS Try...Catch and Throw statements. 5. An introduction to OOP PHP and MySQL. From SitePoint you can also download free the first four chapters of the book: "Build Your Own Database Driven Website Using PHP and MySQL" by Kevin Yank. http://www.sitepoint.com/books/phpmysql1/ Learning this technique you can buld you own content management system, and refactoring and you get full control over refactoring and updating. Note: The great difference between PHP and JavaScript (JS) is that JS code is interpreted by the browser (on the client's Pc) and PHP is interpreted by the webserver. Therefore, the advantage of JS is more flexible dynamic bahavior (action when the mouse is moved) while the disadvantage is that JS is browser dependent. Some useful links: http://www.w3schools.com/ http://www.w3schools.com/js/js_obj_htmldom.asp http://www.w3schools.com/jsref/jsref_events.asp http://msdn.microsoft.com/library/de...scriptinga.asp http://www.javascripter.net/index.html http://msdn.microsoft.com/library/de...methodstoc.asp http://www.javascripter.net/faq/javascr4.htm http://msdn.microsoft.com/library/de...edsecurity.asp http://www.hotscripts.com/ http://www.24fun.com/ http://www.php.net/ http://www.mysql.com/ http://www.sitepoint.com/forums/ Code is Queen, refactoring is King. Recommended book: "The Design and Evolution of C++" by Bjarne Strostrup. ISBN 0-201-54330-3 That book takes to a new level in OOP. |
|
||||
|
|
|
||||
|
1. Component oriented programming.
Build your code, (classes and iterface) by drag and drop. You simply draw your application. 2. We get it free in Norway with SDN Membership! :-) :-) Get Your Free Copy of Java Studio Creator ($99 value) Get Your Free Copy of Java Studio Enterprise ($1,895 value) Get Your Free Copy of Sun Studio ($2,995 value). 3. Join here: http://developers.sun.com/prodtech/devtools/free/ 4. Easy building. Binding a new component in a database is as easy as one, two, three. 1. Drag a component into the Editing Area. 2. Drag the link onto the component. 3. The component is linked to the data, and you can work with it. There is no lack of information and free tools on the internet, the problem is to find the right one. |
|
|||
|
thanks man. been trying to get my head wrapped around OOP for a while and these resouces should help.
|
|
||||
|
1. Php
http://www.phparch.com/shop_dept.php?itemid=5 2. Java, C++, C# and C etc. http://www.deitel.com/books/index.html A much recommended book: Bjørn Kirkerud: Object Oriented Programming With Simula. Addison Wesley Publishing Company ISBN 0 201 17574 6 Some books are classic. They can not be rewritten. You can learn OOP by reading code. You do not need the compiler, but here are some links if you want to dig dig deeper: http://www.hitmill.com/programming/cpp/simula.html http://www.ifi.uio.no/~cim/cim.html http://compilers.iecc.com/index.phtml http://www.idiom.com/free-compilers/TOOL/Simula-1.html Sweeden. The compiler is still in use and used for educational purposes. Personally I have it for IBM OS/II. My son compiled and run Simula programs on it when he was 8 years old. And the code was fast, faster than C++ code when we tested it. OOP without multiple inheritance, private, protected and public variables is quasi OO. A class is nothing more than a container for methods (functions) and properties (variables). An object is an instance of the class, a place in the computers memory. By hiding interface in different classes, you can have the same method and properites in different classes. You start from a general class. A sub class inherits functionality from one or more (multiple inheritance) superclasses. Refactoring become easy with OOP. OOP is especially suited for writing user interface. This should hopefully be more than you ever need. |
|
||||
|
http://heim.ifi.uio.no/~kristen/FORS..._OO_start.html
KW's distributed objects and OOP in large data base projects. OOP in Beta http://www.daimi.au.dk/~beta/books.html, http://heim.ifi.uio.no/~kristen/FORS...hovedside.html is the next level of abstraction. You can download the book free here: ftp://ftp.daimi.au.dk/pub/beta/betabook/betabook.pdf What was the intent of Simula? One aspect was to simulate reality. So it is poosible to use people to simulate behaviour. Each person represent a class with properties and functionality. When persons interact in the play, the project is simplified and simulated. This paper describes abstractions that have been designed to support distributed programming in the object oriented programming language BETA. The approach is minimalistic in the sense that a goal is to provide the essential building blocks on top of which other distribution related abstractions may be built. This goal is made easier by demanding for type orthogonal persistence and distribution as the full power of the underlying language may then be used when building higher level abstractions on top of the basic ones. Download the paper in postscript here http://www.daimi.au.dk/~beta/Papers/....abstract.html (can be converted to PDF with Acrobat reader 7.0 Professional) Related link: http://www.daimi.au.dk/%7Ebeta/doc/f...guage-faq.html In a nutshell, Beta is about minimalism, even if the language is very compact and a large project may be complex. P.S. References in PHP 5.0 is more like references in Java and C++. Even if PHP is interpreted, you may reduce load on your databaseserver by using Aggregation and / or Polymorphism. Read about it in chapter 2 and 3 in the Sitepoint book cited above. |
|
||||
|
As I wrote above, OPP is very good at creating great interface. On a high level it is about making the right data structures, connection classes, set and get methods, containers and iterators on these containers.
Start by using PHP and MySQL. Build your own small CMS. When you are clever at that, you may go to the next step and use Sun Java and draw your application. You start by creeping, then walking and at last running. If you get very clever, you use XP techniques and writes the tests before you write anything else. In a large distributed system, you may need Beta. The sky, your fantasy and creativity set the limit of your ability to write large dynamic databasedriven systems. I have given you some tools and references above. Content and code is Queen. Refactoring is King. |
|
||||
|
Modern computer hardware often consists of a large number of processors connected through some communication media, an example being a set of workstations connected through a local area network. The concurrency described in a BETA program may be realized through time sharing on a single processor, or by distributing the active BETA objects on a number of processors.
Source: ftp://ftp.daimi.au.dk/pub/beta/betabook/betabook.pdf page 17 and 18. And this is important: BETA replaces classes, procedures, functions and types by a single abstraction mechanism called the pattern. It generalizes virtual procedures to virtual patterns, streamlines linguistic notions such as nesting and block structure, and provides a unified framewor for sequential, coroutine and concurrent execution. The resulting language is smaller than Simula in spite of being considerably more expressive. Opt. cit. page 18. Kw's: A single abstraction, called the pattern. |
|
||||
|
1. What is Simula?
The Norwegian company Simula has as far as I know, no relationship to the American . 2. The Simula definition of an object. An object is an entity which may contain data (variables, arrays), operators (procedures, functions) and actions (imperatives). The data and operators of an object are said to be its attributes. A class is a special Simula construct that is used to declare a pattern (or template) for a set of objects that are similar in the sense that they contain the same attributes and imperatives. Objects that conform to the pattern of a given class are generated (created) when special object-generating expressions are evaluated. We note that pattern that is a fundamental concept in Beata, is already mentioned in the above definition of a Simula object. |
|
||||
|
By downloading and installing XAMPP in a few minutes, you have an excellent platform to learn OO PHP. Even Big Blue is concerned about the power of XAMPP
I can reccomend The PHP Anthology: Object Oriented PHP Solutions They teach you OO PHP. The power of PHP is: 1. Very large user base. 2. Good documentation. 3. Large communities. 4. 99% of your problems may be solved if you find the relevant class libraries. 5. Free platform. 6. Simple. 7. You can embed PHP code in URL's. 8. A good platform to more advanced programs. 9. You can switch in and out of PHP. <HTML> <?php Some statements ?> HTML or JavaScript code etc. <?php Some statements ?> HTML or JavaScript code etc. ............................ ............................ <?php Some statements ?> </HTML> Powerful, dynamic and effective. |
|
||||
|
Here is an example of Generic algorithms in C++. It paramtrizes software. Quite general. When you understand this code, you have reached a higher level.
/* GENERIC.CPP: Example of generic algorithms. Templates and generic algorithms. Source: Andrew Koenig: "Templates and generic algorithms" Journal of objectoriented programming june 1994 page 46 and "Generic iterators" Journal of objectoriented programming, september 1994 page 69. */ #include <iostream.h> template<class Ptr, class T> Ptr find(Ptr array, Ptr beyond, const T &x) { Ptr p = array; while (p != beyond && *p != x) ++p; return p; // Returns the address!! } template<class Ptr> void reverse(Ptr start, Ptr beyond) { while (start < beyond ) { --beyond; swap (*start, *beyond); ++start; } } template<class T> void swap(T &x, T &y) { T t = x; x = y; y = t; } int main(){ int x[] = {1,2,3,4,5,6,7,8,9,10}; int y[] = {1,2,3,4,5,6,7,8,9,10}; reverse(&y[0], &y[10]); int i; for (i = 0; i <= 9; ++i) { cout << "x[" << i << "]" << " = " << x[i] << endl; cout << "y[" << i << "]" << " = " << y[i] << endl; } cout << endl; cout << "Finds 8 in x at Hex address: " << find(x,&x[10],8) << endl; cout << "Finds 8 in y at Hex address: " << find(y,&y[10],8) << endl; return 0; } For a theoretical explanation see: Gordon Blair, John Gallagher, David Hutchison and Doug Shephard (1991): "Object Oriented Languages, Systems and Applications." Pitman Publishing ISBN 0-273-03132-5 Chapter 1 - 5, especially chapter 5. An example of exception handling in C++: /* C++ Report October 1994 page 72. PUZZLE.CPP: Problems with exception handling. */ #include <exception.h> int main() { void f(int i) { if (i<=1) throw 1; try { f(i-1); } catch (int c1) { try { f(i-2); } catch (int c2) { throw c1+c2; } } } return 0; } |
|
||||
|
We are incredibly excited to announce that effective April 19th, 2006, all Visual Studio 2005 Express Editions including Visual Basic, Visual C#, Visual J#, Visual C++, and Visual Web Developer Express will be free permanently!
Source:ASP.net May be Microsoft had to do it. Sun Java is a great plattform. XAMPP for Apache + Linux + PHP + MySQL + PHPAdmin ++ are open source and free. According to Visual Studio Express Announcements it is now free. That means that you can get a stripped down platform to learn ASP.NET, Visual C#, Visual C++ etc. That is good enough: With all these advantages, ASP.NET has relatively few downsides. In fact, only two come to mind: - ASP.NET is a Microsoft technology. - Serious ASP.NET developers requires an understanding of object-oriented programming. Source: Build Your Own ASP.NET Website Using C# & VB.NET page 5. ASP.NET pages are compiled, while one of the biggest competitor PHP (XAMPP based on Apache (Linux), PHP, MySQL etc.) is an preprocessor or interpreter. Code is interpreted by the web server and sent to the browser. PHP is a very loosely typed language. That gives felxibility. The main difference is however binding. Compiled code is bound at implementation time, while interpreted code are bound at run time. Run time binding is more felxible. Let us say, you have a shopping chart program that resides in primary storage, that is memory. If the code is compiled, you can think of it as a table. That table is fixed. The connections between different classes are fixed. Run time binding on the other hand implies that the code lives and changes in memory depending on the objects being created at run time. The low hanging fruit of PHP is listed in another WPW thread. Download Visual Web Developer 2005 Express Edition. You find a lot of ASP links in the sticky Programming Resources, Tutorials, etc No need for me to repeat. So now you have three competing platforms: ASP.NET XAMPP Sun Java The choice is yours. Note in some situations, Java Script (that is browser dependent) gives greatest flexibility. Then we are back to where this thread started. |
|
||||
|
|
|
||||
|
This
Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides (1995): "Design Patterns: Elements of Reusable Object-Oriented Software." Addison-Wesley Professional ISBN 0201633612 often cited reference, is referred to as the gang of four in OOP and regarded as a must reading. There is at least, IMO, another gang of four: Gordon Blair, John Gallagher, David Hutchison and Doug Shephard (1991): "Object Oriented Languages, Systems and Applications." Pitman Publishing ISBN 0-273-03132-5 and a gang of three Ole Lehrmann Madsen, Birger Møller-Pedersen and Kristen Nygaard ( 1993): "Object-Oriented Programming in the BETA programming language". Assn for Computing Machinery. ISBN 0201624303 Se OopSchool.com for more information. |
|
|||
|
http://safari.oreilly.com/0596007124 is great for someone that has a decent understanding of OO programming, but doesn't quite get it. The way they present the information is really, really good and their descriptions of patterns make sense.
|
|
||||
|
Here are some related WPW threads:
Manipulating images with code like PHP. Three sites-one database MySql and phpMyAdmin importing code from .txt file. How to solve this (Include) issue in PHP PHP Namespaces / Packages |
|
||||
|
Quote:
I don't know if you looked at php 5.1 yet but it now has excellent OO support. Private and protected class member variables, multiple inheritance and objects automatically passed by reference. No pointers but when you are not manipulating memory you dont need them.
__________________
"I have not failed. I have found 10,000 ways that don't work" - Thomas Edison. "The secret to creativity is knowing how to hide your sources" - Albert Einstein. |
|
||||
|
Quote:
PHP6 - Direction of PHP Have you read that thread? At present I am looking at PHP's image functions and classes. Exciting area. There is also a thread about that above. |
|
||||
|
I dont really see a need for namespaces in php. A lot of php programmers seem to have problems with variable scope (hence the furore when register_globals was deprecated) adding namespaces into the mix would only serve to confuse further.
You can accomplish the same funtionality with static class variables to avoid variable name collisions. C++ Code:
namespace square
{
int x = 5;
int y = 10;
}
namespace rectangle
{
int x = 5;
int y = 10;
}
int main ()
{
using square::x;
using rectangle::y;
cout << x << endl;
cout << y << endl;
}
Code:
class square
{
static $x = 5;
static $y = 10;
}
class rectangle
{
static $x = 5;
static $y = 10;
}
echo square::$x;
echo rectangle::$y;
I would rather see php move to a typed language. No more "$i = 1;", "$i = '1';" rather "int $i = 1;", "string $i = '1';" and have php spit an error when you assign a string to a variable declared as an int.
__________________
"I have not failed. I have found 10,000 ways that don't work" - Thomas Edison. "The secret to creativity is knowing how to hide your sources" - Albert Einstein. |
|
||||
|
But making a namspace a class was left in C++ (see my link to WPW post about namespaces above), but may good enough in PHP.
Namespaces becomes more and more important the more third party class libraries that are constructed. There are already quite a few. Here Testing Conformance to Web Content Accessibility Guidelines is another PHP OOP thread where you may give valuable feedback. It is about accessibility classes in an early stage. Do you know if some such classes are already made? And here is another: Need help developing DynamicToolbar.net. is a related thread where you may contribute. You know PHP better than me, but I am picking up. It is easy compared to C++ :-) |
|
||||
|
The related links to this thread continues to grow. Here are two new:
OOP in PHP and MySQL tips: Start here. I've been told that my Perl, CGI, MYSQL site is obsolete |
|
|||
|
Any more information about how multiple inheritence will work in PHP? My first adventure into programming came from Java, where multiple inheritence was not available and frowned upon. Are we literally talking about something like
class C extends A, B{ } With both the functionality of A and B combined. What happens if both classes declare the same function? Time for me to find and read the PHP6 developers minutes me thinks :-) :-) |
|
||||
|
Yes, multiple inheritance will say that a sub (child) class inherits structure from (extends in PHP) more than one super (parent) class.
In BETA, everything is as described above a pattern. |
|
||||
|
AJAX is a great exasmple of a technology combining JavaScript OO (see start of this thread) with serverside OO (PHP, Java, .NET etc.)
On the IBM AJAX forum, I found a post with the following title: "A Great AJAX Example" where you can download the JoyiStar AJAX WebShop 3 Beta2 sourcecode free. After download, unzip or install it and open the example projects(including Java, C#, VB.Net and PHP) and run it, you will get the same looking as you see at http://219.153.35.21:8080 It is nearly 100 Mb code. "The JoyiStar WebShop is the AJAX web development tools released by JoyiStar corporation. It provides an efficient OOP developing method to construct stable and convenient RichWeb applications based AJAX component". The application is developed in China: "AJAX WebShop 3 won the prize of "Golden Software" in China" I have observed the following: Sitepoint, an Australian forum, is in the front on OO PHP. Romania is in the front on AJAX and now China. Object oriented programming is getting more and more global and AJAX may be a great driver. Note: If you try the online example, it may not function properly in all browsers, so try it in another browser if it does not function in your default browser. My impression is that the application is developed in FireFox, since it functions best in that browser. |
|
||||
|
Nicholas C. Zakas, Jeremy McPeak, Joe Fawcett: "Professional Ajax" (Second edition) is a great book.
Nicholas C. Zakas page has a lot of resources on the download page. I will draw the attention to the floowing two downloads:
There are also a lot of articles on the download page that may be of value to you. At the same time, another OOP language, Ruby is being developed. "Ruby is a reflective, dynamic, object-oriented programming language. It combines syntax inspired by Perl with Smalltalk-like object-oriented features, and also shares some features with Python, Lisp, Dylan and CLU. Ruby is a single-pass interpreted language. Its main implementation is free software". Links: |
|
||||
|
Found this Rails forum today that may be of interest.
|
|
||||
|
Important update on different new technologies related to Web 2.0 technologies. OO is heavily used in the libxml library, that may save you hours of work. There is no need to reinwent the wheel.
I think these posts are important:
XML and Web Services - SitePoint Forums Copy at the DavidCastle forum.
__________________
Mini Network:: Financial information at your fingertips Learn object oriented programming where it started Last edited by kgun; 07-11-2007 at 10:57 AM. |
|
||||
|
If you have read or skimmed so long I will advice you to go back to the first post of this thread. There is a new exellent book from SitePoint, by Kevin Yank & Cameron Adams (my edition September 2007) that I will draw your attention to:
Some important topics of the book:
|
|
||||
|
This thread started with JavaScript, and as stated in the introduction, you can use the W3 Schools online JavaScript editor.
In the console tab of Firebug - Web Development Evolved firebug you can to the same. FireBug is an exellent tool to learn JavaScript and look at code (of other sites). If, as an example, you want to implement Google Maps: Google Map on your site. Find a site that has it implemented and see how it is done in FireBug. In the FireBug world, that is no different from looking at the source code of a page. FireBug can also be used like an advanced validator. How to use FireBug is explained in the first book mentioned in this The desktop is on the Web. thread. Chapter 5 "Metaprogramming with JavaScript" is higly recommended reading. It explains how you can make JavaScript more object oriented with a lot of advanced features. |
|
||||
|
If you are interested in C++ and object oriented this Interview with C++ Creator Bjarne Stroustrup
may be of interest to you. "Then, more than three years ago (after I had moved to Texas A&M University to become a professor ... This thread is soon seen by 10 000 visitors without being a sticky.
__________________
Mini Network:: Financial information at your fingertips Learn object oriented programming where it started Last edited by kgun; 04-17-2008 at 11:42 AM. |
|
||||
|
A few weeks ago I found this
The Mjølner System: Online Information authoritatve link on BETA and related resources that may be of interest to some members / surfers. And don't forget this: Some of these papers are frequently referred to but seldom read, I suspect, since they have not been easily available. IMO referred and cited too seldom and found too deep on the SERP's when you search for object oriented programming in may 2008. Sometimes I get the impression that the SE's is a search tool for Wikipedia.
__________________
Mini Network:: Financial information at your fingertips Learn object oriented programming where it started Last edited by kgun; 05-18-2008 at 12:57 PM. |
|
||||
|
Some updates: php or asp.net as a career ?
|
|
||||
|
Fast answer:
If you look well enough by clicking the last link in my singnature you should find a list. |
|
||||
|
A new thread of interest:
LAMP or .NET This thread is now no #1 on google for: a soft introduction to object oriented programming |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |