0

I'm an experienced Java developer just beginning to learn HTML.

I'm working on a project that uses Spring MVC as a back-end framework. On the front-end, my index page has several rather complex elements, each involving 150+ lines of html. As an OO-programmer at heart, I hate how long my index.html is, and my OO instincts are compelling me to split some/all of these elements off into their own html files, particularly given that there is a possibility that some of them can be reused on other pages. I've come across examples of HTML tags being embedded into one another, but I haven't found much discussion about whether or not doing so is in line with best practices.

What are the best practices when it comes to modularization code reuse and the separation of concerns in modern HTML web-applications?

drew moore
  • 31,565
  • 17
  • 75
  • 112
  • Are you using (or expected to use) a specific [Java web framework](http://en.wikipedia.org/wiki/Comparison_of_web_application_frameworks#Java)? – Richard Ev Mar 17 '14 at 08:41
  • @RichardEverett - yes, I'm using Spring MVC on the backend (Spring-data-Neo4j to be precise). I'm interested to hear how that might affect your answer. – drew moore Mar 17 '14 at 08:44
  • you should specify that in your question, as there are tons of possible solutions – I.G. Pascual Mar 17 '14 at 08:44
  • 1
    @I.G.Pascual Thanks, updated. I'm very curious about what Spring makes possible with regard to my question: I'm relatively new to it as well, and so far have focused mainly on the model and controller aspects of it. What it capacitates with respect to the View is a newer area of thought for me, and I suspect that understanding how it affects this particular question will help me grok that. – drew moore Mar 17 '14 at 08:49
  • I'm not using SpringMVC, but in a java project I work on we use [Sitemesh](http://wiki.sitemesh.org/wiki/display/sitemesh/Home) and [jsp:include](http://stackoverflow.com/questions/9110148/include-another-jsp-file). Hope it helps – I.G. Pascual Mar 17 '14 at 08:56

1 Answers1

0

I feel like some php would help out tons for you, and then you could just do a <?php include 'header.php'; ?> to build everything

nom_nutella
  • 171
  • 1
  • 10
  • 1
    Assuming that the OP wants to learn php, which he has not indicated. – Richard Ev Mar 17 '14 at 08:40
  • I unfortunately don't know any Java so I can't exactly help with that, I am just saying from personal experience what I have done to do basically exactly the same thing – nom_nutella Mar 17 '14 at 08:43
  • 1
    @RichardEverett The OP doesn't have to learn PHP to figure out the include tag. This is an extremely simple process and as a Java developer I'm sure it wouldn't take more than 1 minute of research to understand. – leigero Mar 17 '14 at 08:47