Welcome Guest, Not a member yet? Register   Sign In
Design Logic Help Requested
#1
Lightbulb 
(This post was last modified: 07-12-2016, 11:48 PM by mwebdesign.)

Intro disclaimer: I am struggling with the overall design logic for a large application that I am solely in charge of building at my current workplace. (Please keep in mind that I have never considered myself a "PHP developer" and my boss knows this! When put in charge of this project, I knew it would be a great opportunity to learn the principles of developing a full application, but I find myself struggling with "the basics" that I never even realized I didn't know!) I am not an expert in any area of programming, and most definitely consider myself a novice here, so any constructive criticism is welcome. This being my first ever post to a programming forum asking for help, I'm hoping that my broad question will lead to a more refined discussion and some concrete options of things I can consider and places I might find good examples.

Broad overview: As one of our (the company I work for) products, we sell mobile applications built on a preconfigured (pre as in...before I came on board) "platform" which is basically one big mobile application being utilized as a template for branded versions of said template. I am tasked with building a web application which will #1) give the clients the ability to make changes to the specifics of their branded applications, and eventually #2) let the developers make more advanced changes to those same applications and/or "build" new instances of that template...and possibly in the far future #3) allow clients to build new instances of the template themselves.

Stretch goal: I really want this application to be highly scalable. For instance, I'd love to be able to deliver this application fully functioning, and let them know that "hey, we can also utilize it for future platforms without having to reprogram an entire web app from scratch!"

Some logic 'nitty gritty': This is where I'm finding that I get lost in the crazy number of options there are out there for building a php application. So, what I need is a program that will:
  1. take a logged in user's request for one specific application (passing an $id)
  2. "build" that application, which includes any number of 'features' (of which we have a current variety of 27 choices)
    • and each feature consists of (feature = 1 row in db)
    • specific pieces of data(id, display_type, image, etc), which are stored in their respective columns
      (every feature contains the same top level data piece keys, with varying values)
    • "settings", there is an initial array of them that have the same keys throughout all features, but most features also contain additional settings - all of which are stored as JSON in 1 column of that same db table
    • some features can be 'parents' to other features, to an unspecified depth of parentage
  3. take that appBuild and show it to the user in an incremental, but visual way which will allow them to point and click to make changes to each feature.

    I've gotten much of this figured out. I believe I have the user login, and roles/permissions in hand...I've been working with vue.js and svgs as far as the visuals go...but I'm struggling with organizing the large amount of data that is involved in each individual application. Right now, I've managed to pull in each application and show the details (even though I've only been var_dumping the 'settings data' so far), but it's extremely messy.
    I would really like each Feature to be its own object, and then to have an Application object which contains all of the Feature objects related to that app. (and each Feature to contain one or more Settings objects)....As far as the visual implementation, I'm thinking it needs to be shown "by page". (each page is also considered a Feature though) ie: the Home Page has it's UI setting values plus 3 dynamic Feature objects, each of which have their own UI settings, plus additional settings according to feature type. I feel like utilizing an Abstract Factory design pattern, along with Composite (for the features) is a good plan, but I'm struggling to find an example implementation that really helps me understand how to implement it in the grand scale that I have. They seem to mostly be absurdly simple, or too abstract (foo = bar kind of stuff) for me to really wrap my tired brain around the concepts.

    When looking at my company's current (legacy) solution to this problem (they have something that developers currently use to put together the branded applications), it's a HUGE mess of javascript written in a completely nonsensical manner. They basically pull all the data in for each app and utilize massive if-then statements to sort out what to do with it all... That being said, it works - so what can I say?

    If anyone has any advice on design patterns I should look at or complex examples of applications that sound similar, that would be super! Also, if there is any advice on what kind of things I could utilize helpers or custom libraries for...that would be awesome too. If you would like to see code, please ask! There's just so much of it right now that I couldn't begin to fathom where to start showing it in this initial post...but my hope is that by putting this out there, a more granular discussion can ensue.

    Or, feel free to tell me I'm "on my own" on this too. I'm getting pretty used to that!

Reply
#2

You would need to break the application down into like object modules then break them down into smaller manageable objects

Keep breaking it down until it doe's not make sense to break it down any more.

A good way of doing this is to start with your screen output, it will tell you what variables etc; You will need.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 07-13-2016, 11:16 AM by cartalot.)

* Go on youtube and search for 'clean code robert martin' . he's also known as 'uncle bob'. his lectures on architecture design are timeless. his examples are mostly in java but it actually reads almost exactly the same as codeigniter.

* Naming is very important and you should not hesitate to rename things to make them more clear. use folders to help organize your controllers and models.

* Think in terms of your users and their 'roles' - not data objects. Controllers serve people using them for a specific task. Do not mix roles in a controller. If you need to be logged in to do a task - then that should be in a separate controller that only admins have access to versus a controller that is used for generating a public page.

* Build in your controller and then push your code to models. Models can be used for much more then database interaction. Models can call other models. Models should not do too much - its better to have many small well named, well defined models then a few models that do too many things.

* Views are like scrap paper. Don't do anything important in a view. No application logic. No checking if someone is logged in.

* Get PHPstorm IDE for development. Your company can buy it but they also have monthly payment plans. Theres a thread on this board about the autocomplete file that makes it easy to use with codeigniter. You will have to dedicate some time to learning it but it will save you so much time over the long run. Especially if you are working on a large application.

* You don't have to put everything in one application folder. You can have folders on your server like "alpha1" "alpha2" "beta" etc that point to different application folders.
Reply
#4

@mwebdesign

Do you use CodeIgniter in your platform at all? You have mentioned "a bunch of javascripts", the front-end framework vue.js so far. I wonder whether here is anybody capable to help, we talk about CodeIgniter mostly.

Anyway, I think, you are at risk to face a disaster. I serious company should not put you under such a big challenge, quite bigger than you are. I faced a similar situation ago, it took me about 3 years to get rid of the old code. You need a plan and an estimation on what time and workforce this plan would take. You need understanding and support from your company. As a minimum they should have objective knowledge about the current code quality.
Reply
#5

(07-13-2016, 11:09 AM)cartalot Wrote: * Go on youtube and search for 'clean code robert martin' . he's also known as 'uncle bob'. his lectures on architecture design are timeless. his examples are mostly in java but it actually reads almost exactly the same as codeigniter.

* Naming is very important and you should not hesitate to rename things to make them more clear. use folders to help organize your controllers and models.

* Think in terms of your users and their 'roles' - not data objects. Controllers serve people using them for a specific task. Do not mix roles in a controller. If you need to be logged in to do a task - then that should be in a separate controller that only admins have access to versus a controller that is used for generating a public page.

* Build in your controller and then push your code to models. Models can be used for much more then database interaction. Models can call other models. Models should not do too much - its better to have many small well named, well defined models then a few models that do too many things.

* Views are like scrap paper. Don't do anything important in a view. No application logic. No checking if someone is logged in.

* Get PHPstorm IDE for development. Your company can buy it but they also have monthly payment plans.  Theres a thread on this board about the autocomplete file that makes it easy to use with codeigniter.

I love these quick pointers! Along with the good advice from InsiteFX, I feel like I'm starting to have at least an idea of some solid specific things I can do to start making some positive movement forward. Thank you!!

I think a lot of the problems I've come across so far are due to the fact that I purchased a codeigniter-based program from code canyon, and utilized it as a kind of "starting template"... Many things went great taking this approach...but many other things have gone very badly and have had me writing code to work around the things I can't figure out (from the 'template' code). Anyway, I have learned a lot by doing it this way, but I think it would probably be a good idea for me to rewrite the things I need from the bottom up in a fresh ci environment.

I actually already have PHPStorm Smile ...i just haven't been using it for this project because the 'template code' I have been using looks like a huge mess of warnings when opened in PHPStorm.... I suppose that should've been a big hint huh?
Reply
#6

(07-13-2016, 11:25 AM)ivantcholakov Wrote: @mwebdesign

Do you use CodeIgniter in your platform at all? You have mentioned "a bunch of javascripts", the front-end framework vue.js so far. I wonder whether here is anybody capable to help, we talk about CodeIgniter mostly.

Anyway, I think, you are at risk to face a disaster. I serious company should not put you under such a big challenge, quite bigger than you are. I faced a similar situation ago, it took me about 3 years to get rid of the old code. You need a plan and an estimation on what time and workforce this plan would take. You need understanding and support from your company. As a minimum they should have objective knowledge about the current code quality.

Oh yes, I'm using Codeigniter. I realized after posting my original post that I didn't really make that clear, so a very good question on your part! If you read my response to Cartalot, you'll see that I kind of "shot myself in the foot" by starting off with someone else's interpretation of a program, thinking it would help get me to my goal faster... Unfortunately, at this point, I think I need to take everything I've learned and start from scratch. I'm ok with this, but my work is really pressuring me for "something concrete".

That being said, my direct boss is really on page with where I'm at in this situation. She's been very level-headed with listening to me tell her that the old code base is garbage and was cool with me starting from scratch. Many of the problems I've been facing are due to me trying just not knowing enough...me trying to find the "perfect solution" first and just spending too much time researching instead of writing code....or me trying to utilize others' solutions and bend them to be my own.
Reply
#7

(07-13-2016, 11:09 AM)cartalot Wrote: * Get PHPstorm IDE for development. Your company can buy it but they also have monthly payment plans.  Theres a thread on this board about the autocomplete file that makes it easy to use with codeigniter. You will have to dedicate some time to learning it but it will save you so much time over the long run. Especially if you are working on a large application.

* You don't have to put everything in one application folder. You can have folders on your server like "alpha1" "alpha2" "beta" etc that point to different application folders.

Hey @cartalot...I just read what I believe to be "the thread on this board about the autocomplete file" that you mentioned above. I saw that you contributed a autocomplete config file that was working for you. I've copied it over to see if it's something that might be helpful for me, but I thought I'd ask if you had made any significant changes/improvements to the file since posting it. Do you think your solution has any specific pitfalls I should watch for? Or have you found any other sources that you think work better?

Also, in response to your final paragraph (which I seem to have missed earlier)...I know that CI documentation talks about moving the Application folder, but is there much about making a multiple application folder structure? Either in CI Docs or elsewhere that you know of? Of course, I can google this and that might answer my prematurely asked question, but if you have any input, I'd certainly take it in.

Thanks again!
Reply
#8

WireDesignz HMVC might be useful for you. You can keep all your separate apps in different folders (each with their own views and controllers).

Your 'main' app would just have to deal with permission to access, and calling the separate controllers within the HMVC framework.

Will make testing much easier, keep separation for your apps and it is very robust once you get the hang of it. Building an app like this on the back of a codecanyon example is not a great idea, should definitely be doing this from scratch.

You should also move the settings for each module into their own tables. Much easier to control that way. So module 'projects' reads 'project settings' from a projects_settings table. Much cleaner.

My only advice from a job perspective is to be careful. Your desire for clean lovely code for good reasons may not be shared by your company if they already have code that works. They may be much more along the lines of 'if it aint broke dont fix it', rather than taking the full brunt of the blame for every limitation, bug or issue that arises in the future. Working with the disastrous code at least protects you from the point of view that 'its not your fault, it was how the code was designed in the first place'. And they may not be in a position to wait months and months for your version to come up to production level.

Of course I do not know what your remit or job description is, but a plan moving forward might be to work on both, the live stuff with support, bug fixes and improvements, whilst developing the new version when time allows. It sounds to me like your company was never into making beautiful code if all this is a revelation to them. And your direct report, who is currently understanding and listening, may be saying all sorts of things behind closed doors with her boss.

Good luck,

Paul.
Reply
#9

@mwebdesign

Have a look at this project of mine (The MIT license): https://github.com/ivantcholakov/starter...-edition-4
If you think that it could be useful, enable receiving private messages in your profile in this forum and send me a private message. I will give you for free source to a small CMS built on top of this starter. I think, it will give you an idea how you could structure your code with scalability in mind, without much talking. It would not fit exactly to what you need, some features you should port/write alone, but at least you will start at a higher level.

But honestly, I still feel skepticism. I hope I am wrong.
Reply
#10

@ivantcholakov
I agree, will be interesting to hear how it went or is going in three and six months time.
That link you posted, wow, you have put so much work into all that. Quite impressive. That must have taken ages.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB