UML TO PHP CLASS
Moderator: General Moderators
UML TO PHP CLASS
How to create class from uml,
i have uml like this,
MemberTypes
-MemberTypeId
-MemberTypeName
-MemberTypeDesc
+AddMemberType()
+DeleteMemberType()
How to write class file for above.
Thanks
i have uml like this,
MemberTypes
-MemberTypeId
-MemberTypeName
-MemberTypeDesc
+AddMemberType()
+DeleteMemberType()
How to write class file for above.
Thanks
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
Re: UML TO PHP CLASS
Usually the editor you use to create the UML should have this feature (to export to PHP,JAVA etc).kpraman wrote:How to create class from uml,
i have uml like this,
MemberTypes
-MemberTypeId
-MemberTypeName
-MemberTypeDesc
+AddMemberType()
+DeleteMemberType()
How to write class file for above.
Thanks
I'm trying to find such a tool as well...but for php it is quite hard....java is more strict...and easier to implement such tool I guess.
+ this will only be possible for php5 ..thats for sure.
Umbrello can do it. It has some weak points, but it's free, which is a big plus.
Code: Select all
/**
* class MemberTypes
*/
class MemberTypes
{
/** Aggregations: */
/** Compositions: */
/*** Attributes: ***/
/**
* @access private
*/
private $MemberTypeId;
/**
* @access private
*/
private $MemberTypeName;
/**
* @access private
*/
private $MemberTypeDesc;
/**
*
* @return
* @access public
*/
public function addMemberType( ) {
} // end of member function addMemberType
/**
*
* @return
* @access public
*/
public function deleteMemberType( ) {
} // end of member function deleteMemberType
} // end of MemberTypes
?>i want to pass values of $MemberTypeId,$MemberTypeName,$MemberTypeDesc and in the method,
public function addMemberType(), i want to insert into database. "INSERT INTO tblname SET membertypename='$MemberTypeName, membertypedesc='$MemberTypeDesc'".
similarly for deleteMemberType( ), "DELETE FROM tblname WHERE membertypeid='$MemberTypeId'";
public function addMemberType(), i want to insert into database. "INSERT INTO tblname SET membertypename='$MemberTypeName, membertypedesc='$MemberTypeDesc'".
similarly for deleteMemberType( ), "DELETE FROM tblname WHERE membertypeid='$MemberTypeId'";
Well, I did not point it out correctly. This will only make sense for php5...in my opinion. php4 just lacks so many OOP features that UMLing the classes is kind of pointless. Just php4 sux in OOP thats all, and UML is to express OOP approach.Weirdan wrote:What would prevent you from outputting valid php4 code? If SimpleTest can do that (generate mocks), any application can do that as well.+ this will only be possible for php5 ..thats for sure.
i wrote the code like this,
This works fine. Since in the UML the variablname, $MemberTypeName, $MemberTypeDesc are marked a private (-), how to implement it?
Code: Select all
<?php
class MemberTypes{
public function addMemberType($MemberTypeName, $MemberTypeDesc, $tblname) {
$query=mysql_query("INSERT INTO $tblname SET membertypename='$MemberTypeName', membertypedesc='$MemberTypeDesc'");
}
}
$newCls= new MemberTypes();
$newCls->addMemberType('Admin', 'Assigns membership', $tblname);
?>ever heard of "poseidon" for uml generation.
only used it for java coe generation but it seems to have an old plugin for php4 code generation. but haven't investigate further.
try it and tell us what u've got
http://www.gentleware.com/73.html
only used it for java coe generation but it seems to have an old plugin for php4 code generation. but haven't investigate further.
try it and tell us what u've got
http://www.gentleware.com/73.html
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
I think you're missing the point. Before you start playing with UML I'd probably try to understand OOP syntax first. $MemberTypeName, $MemberTypeDesc are properties, not function parameters or local variables (i.e. you access them with $this->.... ). The fact that they are private won't affect using them from inside the class, and if you need to adjust the values from outside just create public setMemberTypeName($value), setMemberTypeDesc($value) methods which can do it for you.kpraman wrote:i wrote the code like this,
This works fine. Since in the UML the variablname, $MemberTypeName, $MemberTypeDesc are marked a private (-), how to implement it?Code: Select all
<?php class MemberTypes{ public function addMemberType($MemberTypeName, $MemberTypeDesc, $tblname) { $query=mysql_query("INSERT INTO $tblname SET membertypename='$MemberTypeName', membertypedesc='$MemberTypeDesc'"); } } $newCls= new MemberTypes(); $newCls->addMemberType('Admin', 'Assigns membership', $tblname); ?>