Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

11
Inlined code and CRUD applications.
Post Body

I read some weeks ago this blog post on John Carmack talking about inlined code (What I understood to be -english is not my first language, so please bear with me- the need, or lack of need of moving chunks of code to functions, even though those functions aren't going to be called more than once), and it has kept me wondering for a while, bot on how I write code and what I've seen around my (short) laboral experience.

Now, I've been working for a bit of time on your standard, boring J2EE corporate applications, and I've found a strange (for me) tendency to avoid separation of chunks of code into auxiliar functions in favor of "monolithic" chunks of code over 200 or 300 lines long.

I've seen this specially on "front/facade" classes, where the application "receives" input, either a REST service class or a class that handles the drawing of a web page. For instance, in Vaadin (A framework that allows you to make webpages using Java code), there could be a single function called "generateBody" with several hundred lines. I would separate that code into different chunks (what would end up being divs on the main function), and have the main function be, let's say, some dozens of lines of code wide, replacing the actual code for "element A" for a "generateA" function that returns the element.

I can understand that too much branching into different functions can lead to a code that is more complex to read through way too much function calls, but I can't wrap my head around why writing one function with 1000 lines of code is better than having some functions and subfunctions (arranged in what I hope is a logical manner), besides having to work on "auto mode" due deadlines and such.

I don't really know what could be the question here, as I'm wondering if something in my way of thinking is off, if almost everyone I've seen on companies writing code are doing it wrong (or at least "not really well") or what (if something) could learn from this question. So, any thoughts on the topic?

Author
Account Strength
100%
Account Age
12 years
Verified Email
Yes
Verified Flair
No
Total Karma
174,649
Link Karma
7,855
Comment Karma
166,120
Profile updated: 2 days ago
Posts updated: 10 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
7 years ago