Welcome Guest, Not a member yet? Register   Sign In
Restructuring/code clean up
#1

OK so you got some code and it works pretty nicely except, it is all sort of over the place and not really organised.

You want to structure it in a way that is organised because it is something everyone has the potential to see and use and possibly amend.

This includes a logical and sensible file structure, organised logical string of methods, and tidy html views and css js files.

Where do you start?

I looked at using html/css beautifiers to dump out better view files. Tried to keep consistent naming of methods and spacing, might use a PHP beautifier on it too. File structure is pretty much own preference at the minute.

What do you do, this question is specifically aimed at github users who have clean readable code.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#2

Anyone?
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#3

If I created a module and consider it finished (feature wise working order) I start refactoring it, moving code from controller to models to make more sense and document every method.

You can setup your editor to use PHP_CodeSniffer. This could help you to force you to code (php) following a certain style guide. Most editors support this (Sublime, Atom, Php storm) to auto format your code on file save for example or with a shortkey.

You can use PSR-2, the CodeIgniter style guide or your personal preference. The most important thing is readability.

Same applies for html/css, just indent every new element the same way.
Reply
#4

Thanks, I'm on sublime and I'm going to try this.

https://github.com/akalongman/sublimetext-codeformatter

I have a bit of a problem with my github code as the PHP seems all over the place, could this be because I need to convert tabs to spaces?
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#5

(02-07-2017, 06:00 AM)Diederik Wrote: If I created a module and consider it finished (feature wise working order) I start refactoring it, moving code from controller to models to make more sense and document every method.
Forgot to add that during the refactoring stage I try to put all visible content into language files.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB