Differences from version 3 to 5



@@ -5,46 +5,52 @@

 # what should come out of it
 
 Here is a simple PHP object to help explain how this works:
-{CODE(colors=>php)}class MyClass {
+{CODE source=php}class MyClass {
  // internal variable - should never be accessed
  // externally.
  var mText;
- // initialisation - set default text to "not-set"
+ // initialisation - set default text to "not-set"
  function MyClass() {
- $this->mText = "not-set";
+ $this->mText = "not-set";
  }
  // get the text using this function
  function getText() {
- return $this->mText;
+ return $this->mText;
  }
  // set the text using this function
  function setText($x) {
- $this->mText = $x;
+ $this->mText = $x;
  }
-}{CODE}
+}{/CODE}
 The first internal variable you can see is __mText__. It is recommended in Object Orientation (OO) that you (almost) never access internal variables except from within the class itself. Hence will never need to know the internals of the class and if developers don't go changing the internal variables, everything is a lot easier to control.
 
 Secondly, if everything goes through functions, you can validate data going in to the class and make sure its not going to break things.
 
 The first function we see is __MyClass()__. This is a ''constructor'' or initialisation function. This function is always called when you create a new instance of this class. Below is how you create an instance:
-{CODE(colors=>php)}$quickTest = new MyClass();{CODE}
+{CODE source=php}$quickTest = new MyClass();{/CODE}
 Simple hey. Now, we want to see the text inside the class. Although you cannot hide the internal variables in PHP4, PHP5 has introduced methods to prevent users accessing internal variables. So I can only emphasise - don't access the internal variables directly. So we've created the class, lets have a look whats inside:
-{CODE(colors=>php)}$quickTest = new MyClass();
-echo "Whats the value: ".$quickTest->getText()."<br/>";{CODE}
-{CODE()}Whats the value: not-set{CODE}
+{CODE source=php}$quickTest = new MyClass();
+echo "Whats the value: ".$quickTest->getText()."<br/>";{/CODE}
+{CODE source=c}Whats the value: not-set{/CODE}
 So we can see that the default value, which is set during initialisation is there.
 Next, we want to set the text with something new. Again (I can't emphasise this enough) - don't access the internal variables directly. So here's how we do it:
-{CODE(colors=&gt;php)}$quickTest = new MyClass();
-echo &quot;Whats the value: &quot;.$quickTest-&gt;getText().&quot;&lt;br/&gt;&quot;;
-$x = &quot;some new text&quot;;
-echo &quot;Set the value: &quot;.$x.&quot;&lt;br/&gt;&quot;;
-$quickTest-&gt;setText($x);
-echo &quot;Whats the value: &quot;.$quickTest-&gt;getText().&quot;&lt;br/&gt;&quot;;{CODE}
-{CODE()}Whats the value: not-set
+{CODE source=php}$quickTest = new MyClass();
+echo "Whats the value: ".$quickTest->getText()."<br/>";
+$x = "some new text";
+echo "Set the value: ".$x."<br/>";
+$quickTest->setText($x);
+echo "Whats the value: ".$quickTest->getText()."<br/>";{/CODE}
+{CODE source=c}Whats the value: not-set
 Set the value: some new text
-Whats the value: some new text{CODE}
+Whats the value: some new text{/CODE}
 This is a really simple example, but it is the essence of how OO works. have a look at TestingSuites, which rely on this methodology to work.
 
-When you start designing classes, contrary to the code above, you should never include presentation code. Take a look at ModelViewController to understand where the data classes and libraries (the Model) fit into the scheme of things.
+When you start designing classes, contrary to the code above, you should not include presentation code. Take a look at Model View Controller - MVC to understand where the data classes and libraries (the Model) fit into the scheme of things. Also, dependancies on libraries and base classes should be refined and minimal.
 
-Also have a look at ClassStructure for a more detailed look into the use of classes and OO in TikiPro.
+Also have a look at ClassStructure for a more detailed look into the use of classes and OO in bitweaver.
+
+If you are trying to get __kernel/test/__ working, you'll need to do these two things:
+# Move your kernel/adodb/ directory to util/adodb/. HEAD code will continue to work, so don't get worried yet.
+# In your config_inc.php file, place a URI:
+ $dbSettings = "dbtype://user:pass@mydb/dbname";
+where dbtype is the Adodb driver names or abbreviations - mysql, mssql, pgsql, sybase, oci, firebird15, etc.
Page History
Date/CommentUserIPVersion
11 Mar 2006 (11:43 UTC)
Uwe Zimmermann87.96.133.2195
Current • Source
Stephan Borg218.214.1.1134
View • Compare • Difference • Source
Stephan Borg218.214.1.1133
View • Compare • Difference • Source
Stephan Borg218.214.1.1132
View • Compare • Difference • Source