OOP php用户系统 [英] OOP php user system

查看:49
本文介绍了OOP php用户系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,


虽然我已经使用了类和对象很长一段时间了但是现在我没有实际编写正确的OO代码然而。它当然取决于

你称之为正确的OO代码。我一直在分离

网站的部分内容。就像用户类,留言簿等等。但是我已经将所有代码放在一个单独的类而不是拼出它。


很久以来我一直在阅读OOP,现在我正在努力实现
实际按照他们应该做的方式来做一个很好的

可维护的模块。这实际上意味着我正在努力坚持

一些规则:不要重复自己,分离关注点,

封装等等。 >

我已创建(尚未完成它)一个用户系统,这个

根据mvc模式。类的名称并不完美

(用户实际应该命名为userController,userData应该是

命名用户等)。


你们中的任何人都可以看看我是否会向右走

方向?


少数几个类(为了方便阅读而放在一个文件中)

可以在这里找到: http://web-develop.nl/user_oop.phps

希望你们能给我一些有用的评论。


谢谢

Hey,

Although I''ve been using classes and object for quite a while now I''ve
never actually programmed proper OO code yet. It ofcourse depends on
what you call proper OO code. I have been seperating parts of the
website. Like a user class, guestbook class, etc. But I''ve been
putting all the code in one single class instead of of spreiding it.

Since a short while I''ve been reading up on OOP and now I am trying to
actually do things the way they should be done to make a nice
maintainable module. Which in fact means that I''m trying to stick to
some rules: Don''t repeat yourself, seperation of concerns,
encapsulation, etc.

I''ve created (not finished just started it) a user system, this
according to the mvc pattern. The names for the classes aren''t perfect
(user should actually be named userController, and userData should be
named user, etc.).

Could any of you guys have a look and see if I''m going in the right
direction?

The few classes (put in a single file for the sake of easy reading)
can be found here: http://web-develop.nl/user_oop.phps

Hope you guys can give me some useful comments.

Thanks

推荐答案



" Yorian" < yo ************ @ hotmail.comwrote in message

news:8b ****************** **************** @ t39g2000 prh.googlegroups.com ...

"Yorian" <yo************@hotmail.comwrote in message
news:8b**********************************@t39g2000 prh.googlegroups.com...

嘿,


虽然我已经使用了类和对象很长一段时间了但是现在我还没有实际编写正确的OO代码。它当然取决于

你称之为正确的OO代码。我一直在分离

网站的部分内容。就像用户类,留言簿等等。但是我已经将所有代码放在一个单独的类而不是拼出它。


很久以来我一直在阅读OOP,现在我正在努力实现
实际按照他们应该做的方式来做一个很好的

可维护的模块。这实际上意味着我正在努力坚持

一些规则:不要重复自己,分离关注点,

封装等等。 >

我已创建(尚未完成它)一个用户系统,这个

根据mvc模式。类的名称并不完美

(用户实际应该命名为userController,userData应该是

命名用户等)。


你们中的任何人都可以看看我是否会向右走

方向?


少数几个类(为了方便阅读而放在一个文件中)

可以在这里找到: http://web-develop.nl/user_oop.phps

希望你们能给我一些有用的评论。
Hey,

Although I''ve been using classes and object for quite a while now I''ve
never actually programmed proper OO code yet. It ofcourse depends on
what you call proper OO code. I have been seperating parts of the
website. Like a user class, guestbook class, etc. But I''ve been
putting all the code in one single class instead of of spreiding it.

Since a short while I''ve been reading up on OOP and now I am trying to
actually do things the way they should be done to make a nice
maintainable module. Which in fact means that I''m trying to stick to
some rules: Don''t repeat yourself, seperation of concerns,
encapsulation, etc.

I''ve created (not finished just started it) a user system, this
according to the mvc pattern. The names for the classes aren''t perfect
(user should actually be named userController, and userData should be
named user, etc.).

Could any of you guys have a look and see if I''m going in the right
direction?

The few classes (put in a single file for the sake of easy reading)
can be found here: http://web-develop.nl/user_oop.phps

Hope you guys can give me some useful comments.



我最喜欢的东西,Yorian,它的格式很好!我不知道

评论的语言是什么,但我确实认识到''singleton''。对于

作为单例的类,你需要将__constructor设为

私函数,并使用''static''关键字作为其他

函数/类中的变量。你真的需要一种方法来提供构造者args的那些单身人士。你可以让调用者通过''setters''设置

值和/或创建一个静态函数,比如''initialize'',

基本上执行__construct的责任。你应该考虑将__clone,__ copy等定义为私有,所以

保证不会有多个单例实例。


再次,我最喜欢代码,因为我可以很容易地告诉它是什么,因为它的格式很好。最重要的是,当你需要添加它或在

未来以某种方式修改它时,这将节省时间,金钱,

和挫折。


干杯

The thing I like most, Yorian, is that it is well formatted! I don''t know
what language the comments are in, however I do recognize ''singleton''. For
the classes that are singletons, you need to make the __constructor a
private function and use the ''static'' keyword for the other
functions/variables in the class. You''d necissarily need a way to supply
those singletons the constructor args. You can either let the caller set the
values via ''setters'' and/or create a static function, like ''initialize'',
that essentially carries out the responsibility of __construct. You should
also think about defining __clone, __copy, etc. specifically as private so
that you are guaranteed not to have more than one instance of the singleton.

Again, I like the code most because I can readily tell what it is
doing...because it is well formatted. Above all, that will save time, money,
and frustration when you need to add to it or modify it in some way in the
future.

Cheers


11月9日,10:37 * pm,Jessica Griego < j ... @ example.comwrote:
On Nov 9, 10:37*pm, "Jessica Griego" <j...@example.comwrote:

" Yorian" < yorianbenja ... @ hotmail.comwrote in message


新闻:8b *********************** *********** @ t39g2000 prh.googlegroups.com ...
"Yorian" <yorianbenja...@hotmail.comwrote in message

news:8b**********************************@t39g2000 prh.googlegroups.com...

嘿,
Hey,


虽然我已经使用了类和对象很长一段时间了但是现在我还没有实际编写正确的OO代码。它当然取决于

你称之为正确的OO代码。我一直在分离

网站的部分内容。就像用户类,留言簿类等一样。但是我已经将所有代码放在一个单独的类而不是spreiding它。
Although I''ve been using classes and object for quite a while now I''ve
never actually programmed proper OO code yet. It ofcourse depends on
what you call proper OO code. I have been seperating parts of the
website. Like a user class, guestbook class, etc. But I''ve been
putting all the code in one single class instead of of spreiding it.


因为很短的时间我一直在读OOP而现在我正在努力实现
实际做事情应该如何做一个漂亮的

可维护模块。这实际上意味着我正在努力坚持

一些规则:不要重复自己,分离关注点,

封装等等。
Since a short while I''ve been reading up on OOP and now I am trying to
actually do things the way they should be done to make a nice
maintainable module. Which in fact means that I''m trying to stick to
some rules: Don''t repeat yourself, seperation of concerns,
encapsulation, etc.


我已创建(尚未完成它)用户系统,根据mvc模式,这是

。类的名称并不完美

(用户实际应该命名为userController,userData应该是

命名用户等)。
I''ve created (not finished just started it) a user system, this
according to the mvc pattern. The names for the classes aren''t perfect
(user should actually be named userController, and userData should be
named user, etc.).


你们中的任何人都可以看一下,看看我是否会向右走

方向?
Could any of you guys have a look and see if I''m going in the right
direction?


几个类(为了方便阅读而放在一个文件中)

可以在这里找到:< a rel =nofollowhref =http://web-develop.nl/user_oop.phpstarget =_ blank> http://web-develop.nl/user_oop.phps


希望你们能给我一些有用的评论。
Hope you guys can give me some useful comments.



我最喜欢的东西,Yorian,它的格式很好!我不知道

评论的语言是什么,但我确实认识到''singleton''。对于

作为单例的类,你需要将__constructor设为

私函数,并使用''static''关键字作为其他

函数/类中的变量。你真的需要一种方法来提供构造者args的那些单身人士。你可以让调用者通过''setters''设置

值和/或创建一个静态函数,比如''initialize'',

基本上执行__construct的责任。你应该考虑将__clone,__ copy等定义为私有,所以

保证不会有多个单例实例。


再次,我最喜欢代码,因为我可以很容易地告诉它是什么,因为它的格式很好。最重要的是,当你需要添加它或在

未来以某种方式修改它时,这将节省时间,金钱,

和挫折。


干杯


The thing I like most, Yorian, is that it is well formatted! I don''t know
what language the comments are in, however I do recognize ''singleton''. For
the classes that are singletons, you need to make the __constructor a
private function and use the ''static'' keyword for the other
functions/variables in the class. You''d necissarily need a way to supply
those singletons the constructor args. You can either let the caller set the
values via ''setters'' and/or create a static function, like ''initialize'',
that essentially carries out the responsibility of __construct. You should
also think about defining __clone, __copy, etc. specifically as private so
that you are guaranteed not to have more than one instance of the singleton.

Again, I like the code most because I can readily tell what it is
doing...because it is well formatted. Above all, that will save time, money,
and frustration when you need to add to it or modify it in some way in the
future.

Cheers



您可以使用

泛型__get方法返回,而不是使用所有这些getAttribute方法属性。


Thomas

Instead of using all of those getAttribute methods, you could use a
generic __get method that returns the attribute.

Thomas


11月9日,10:46 * pm,703designs< thomasmal ... @ gmail .comwrote:
On Nov 9, 10:46*pm, 703designs <thomasmal...@gmail.comwrote:

11月9日,10:37 * pm,Jessica Griego < j ... @ example.comwrote:
On Nov 9, 10:37*pm, "Jessica Griego" <j...@example.comwrote:

" Yorian" < yorianbenja ... @ hotmail.comwrote in message
"Yorian" <yorianbenja...@hotmail.comwrote in message


news:8b *************** ******************* @ t39g2000 prh.googlegroups.com ....
news:8b**********************************@t39g2000 prh.googlegroups.com....


嘿,
Hey,


虽然我一直在使用课程和对象相当一段时间我现在还没有实际编写正确的OO代码。它当然取决于

你称之为正确的OO代码。我一直在分离

网站的部分内容。就像用户类,留言簿类等一样。但是我已经将所有代码放在一个单独的类而不是spreiding它。
Although I''ve been using classes and object for quite a while now I''ve
never actually programmed proper OO code yet. It ofcourse depends on
what you call proper OO code. I have been seperating parts of the
website. Like a user class, guestbook class, etc. But I''ve been
putting all the code in one single class instead of of spreiding it.


很短的时间我一直在阅读OOP,现在我正在尝试实际上按照他们应该做的方式来做一些好的

可维护模块。这实际上意味着我正在努力坚持

一些规则:不要重复自己,分离关注点,

封装等等。
Since a short while I''ve been reading up on OOP and now I am trying to
actually do things the way they should be done to make a nice
maintainable module. Which in fact means that I''m trying to stick to
some rules: Don''t repeat yourself, seperation of concerns,
encapsulation, etc.


我已创建(尚未完成它)用户系统,这个
根据mvc模式
。类的名称并不完美

(用户实际应该命名为userController,userData应该是

命名用户等)。
I''ve created (not finished just started it) a user system, this
according to the mvc pattern. The names for the classes aren''t perfect
(user should actually be named userController, and userData should be
named user, etc.).


你们中的任何人都可以看一看,看看我是否会参加对了

方向?
Could any of you guys have a look and see if I''m going in the right
direction?


少数类(为了方便阅读而放在一个文件中)

可以在这里找到: http://web-develop.nl /user_oop.phps


希望你们能给我一些有用的评论。
Hope you guys can give me some useful comments.


我最喜欢的东西,Yorian,它的格式很好!我不知道

评论的语言是什么,但我确实认识到''singleton''。对于

作为单例的类,你需要将__constructor设为

私函数,并使用''static''关键字作为其他

函数/类中的变量。你真的需要一种方法来提供构造者args的那些单身人士。你可以让调用者通过''setters''设置

值和/或创建一个静态函数,比如''initialize'',

基本上执行__construct的责任。你应该考虑定义__clone,__ copy等,特别是作为privateso

你保证不会有多个单例的实例。
The thing I like most, Yorian, is that it is well formatted! I don''t know
what language the comments are in, however I do recognize ''singleton''. For
the classes that are singletons, you need to make the __constructor a
private function and use the ''static'' keyword for the other
functions/variables in the class. You''d necissarily need a way to supply
those singletons the constructor args. You can either let the caller set the
values via ''setters'' and/or create a static function, like ''initialize'',
that essentially carries out the responsibility of __construct. You should
also think about defining __clone, __copy, etc. specifically as privateso
that you are guaranteed not to have more than one instance of the singleton.


再次,我最喜欢这些代码,因为我可以很容易地告诉它是什么

做...因为它是格式正确。最重要的是,当您需要添加或以某种方式在

未来修改它时,这将节省时间,金钱,

和挫败感。
Again, I like the code most because I can readily tell what it is
doing...because it is well formatted. Above all, that will save time, money,
and frustration when you need to add to it or modify it in some way in the
future.


干杯
Cheers



除了使用所有这些getAttribute方法,你可以使用

返回属性的泛型__get方法。

Thomas


Instead of using all of those getAttribute methods, you could use a
generic __get method that returns the attribute.

Thomas



啊,我的错,晚了。我的意思是你可以使用__get自动使用call_user_func指向

这些方法。这样

Ah, my fault, it''s late. I meant that you can use __get to point to
those methods automatically using call_user_func. So that


这篇关于OOP php用户系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆