Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Help! Too many includes/imports.

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #178770
    nixnerd
    Participant

    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?

    #178773
    __
    Participant

    …autoloading?

    for PHP, anyway. dunno about SASS.

    #178774
    nixnerd
    Participant

    Well, 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.

    #178775
    shaneisme
    Participant

    If 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…

    #178776
    Alen
    Participant

    Start 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.

    #178777
    nixnerd
    Participant

    @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?

    #178781
    __
    Participant

    wait 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 includes 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.

    #178783
    __
    Participant

    _

    by the way it’s “__” not “_”

    THUNDERSCORE!! woooot!
    I was going for something nerdy and ethereal but I guess I went too far

    #178786
    Alen
    Participant

    #178787
    chrisburton
    Participant

    So, 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!

    #178788
    nixnerd
    Participant

    THUNDERSCORE!! 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.

    #178923
    __
    Participant
    #178945
    nixnerd
    Participant

    I have dealt with it. Now it’s time to refactor and…

    #180119
    RioBrewster
    Participant

    I 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?

    #180177
    shaneisme
    Participant

    Optimally 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

Viewing 15 posts - 1 through 15 (of 20 total)
  • The forum ‘Other’ is closed to new topics and replies.