douben7493 2014-03-16 19:13
浏览 40

如何为我的PHP类选择正确的架构?

This is the first web app that i am building by myself.

Before coding i like to organize my ideas, do class and requiriments diagrams.

So i have to do this in my software

-Add users. -Add buy orders.

I am thinking my classes in two different ways.

Like this:

class User{
    function add()
    function edit()
}

class BuyOrder{
    function add()
    function edit()
}

Or

class Add{
   function user()
   function buyOrder()
}

class Edit{
    function user()
    function buyOrder()
}

As you can see they will do the same but with different writting.

Any ideas?

thanks

  • 写回答

2条回答 默认 最新

  • doujiebo9849 2014-03-16 19:32
    关注

    I think User and BuyOrder should be a class.

    However, it doesn't make sense to me to have an add function be a part of these classes since the creation of a new instance of these classes effectively is the add.

    Instead I would create AddUser and AddOrder functions which create the instances and properly add them where they need to be.

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度