- This topic is empty.
-
AuthorPosts
-
August 12, 2014 at 1:10 pm #178770nixnerdParticipant
I have one project that spiraled out of control VERY quickly. I generally code in a very modular fashion. I try to live by the ethos “Loose coupling and tight cohesion.” Naturally, if I’m developing a new feature… I’ll code up JUST that feature and graft it into the rest of the code base.
However… on this project, we just kept adding features and it got crazy… fast.
So, I have about 1 billion PHP includes and SASS imports.
This is normally fine… when there’s a lot less. Now, it’s become VERY hard to maintain.
Any suggestions on how to fix this nonsense?
August 12, 2014 at 1:34 pm #178773__Participant…autoloading?
for PHP, anyway. dunno about SASS.
August 12, 2014 at 1:38 pm #178774nixnerdParticipantWell, it’s really not a performance issue. Hell, who knows? Maybe it is. I don’t actually write any PHP for this project.
But when I want to go in and change something… there’s ALWAYS the issue of:
Sh*t! What file is this in??
It’s really a pain.
August 12, 2014 at 1:43 pm #178775shaneismeParticipantIf your project is organized like a SPA, you’ll have that single entry point for everything to branch out from and finding things will be trivial. And like… wait which one of you used to be Joe? I think _ is the coder formerly known as Joe, so like he said autoloading makes things very simple.
In SASS, I’ve never had any includes other than the ones in the main file that compiles everything together. All the individual files are just logically grouped together in things like “tables”, “text”, etc…
August 12, 2014 at 1:44 pm #178776AlenParticipantStart refactoring.
@chrisburton, this post pretty much sums up the need of OOP. So if you’re ever wondering do I need OOP. This is it.Sorry @Joe_Temp
Can you elaborate little bit on how you have your project organized. Also, why would Sass includes be an issue. Unless you abstracted the hell out of the code, that piecing it together is troublesome.
August 12, 2014 at 1:50 pm #178777nixnerdParticipant@shaneisme I’m the coder formerly known as Joe_Temp.
@chrisburton He’s right… THIS is the reason.
@alenabdula It’s all good. Part of the problem is collaboration with other people who… don’t do things the way I do them to put it nicely.You think that’s really the only solution? Should I just start a branch called refactor and start cleaning stuff up?
August 12, 2014 at 3:02 pm #178781__Participantwait which one of you used to be Joe?
lol… I should change my display name to Joe
that’ll solve everything!Part of the problem is collaboration with other people who… don’t do things the way I do them to put it nicely.
That will always be a sticking point. But abstracting and modularising things will also help your code be more adaptable when you need to work with people who don’t think about things like that. If your code is self-contained, then writing an adapter class (a “façade“) and sticking it into someone else’s workflow gets easier.
Joe, remember a while back, we were talking about an API for “people who work together” as opposed to an API for software? That dream is lookin’ pretty good right about now, huh?
In the meantime, yes, definitely look into using an autoloader. You can completely eliminate the need for explicit
include
s from your code.You think [refactoring]’s really the only solution?
Unfortunately… probably, yes.
But don’t “jump in” until you’ve figured out a good solution and plan-of-attack. Then start doing little chunks at a time.
August 12, 2014 at 3:12 pm #178783__Participant_
by the way it’s “__” not “_”
THUNDERSCORE!! woooot!
I was going for something nerdy and ethereal but I guess I went too farAugust 12, 2014 at 3:19 pm #178786AlenParticipantAugust 12, 2014 at 3:21 pm #178787chrisburtonParticipantSo, I have about 1 billion PHP includes and SASS imports.
That takes bravery.
@chrisburton, this post pretty much sums up the need of OOP. So if you’re ever wondering do I need OOP. This is it.
Haha. Fortunately, I do know better than that!
August 12, 2014 at 3:21 pm #178788nixnerdParticipantTHUNDERSCORE!! woooot!
Ha ha ha ha.
I was going for something nerdy and ethereal but I guess I went too far
I’d say you nailed it.
I’ll look into an autoloader and try to figure out another way this can be done.
August 13, 2014 at 12:05 pm #178923__ParticipantAugust 13, 2014 at 2:35 pm #178945nixnerdParticipantI have dealt with it. Now it’s time to refactor and…
August 21, 2014 at 6:33 am #180119RioBrewsterParticipantI have a similar issue.
We are cleaning up and redoing humungous site (at least 500,000 pages) that still has code dating back to the last century. There is inline css, css directories and include directories everywhere in the sprawling structure.
So we plan to break it up into separate sites, but with common things like footers, a global nav and similar page structure and framework files. We are using Foundation 4 with SASS (don’t get me started on F5).
In reaction to the nastiness of the existing site, there are those that want to structure the code like this:
/css/app.css
/css/site1/site1.css
/css/site2/site2.css
…
/includes/(global includes)
/includes/site1/(site 1 includes)
/includes/site2/(site 2 includes)
…
/images/(global images)
/images/site1/(site 1 images)
/images/site2/(site 2 images)
…
/site1/
/site2/
…I think this is madness – and it will drive me crazier than that awful gif in @NIX’s last post. :^)
I would rather see global/framework stuff at the root, and includes/css that is specific to the subsites at the root of that sub site, and images relative to where they are used.
The other question – where do nav includes go? A /nav/ directory or under /includes/
Thoughts?
August 21, 2014 at 3:55 pm #180177shaneismeParticipantOptimally any HTML will be part of a template which is built from a master template which are all parts of your views.
If you really do have 500K pages, each of those will be the body portion of the template.
You’ll only have one “header”, “menu”, “footer”, etc. that they all live inside.
What you name the stuff is up to you guys.
There are only two hard things in Computer Science: cache invalidation and naming things. — Phil Karlton
-
AuthorPosts
- The forum ‘Other’ is closed to new topics and replies.