Follow Slashdot blog updates by subscribing to our blog RSS feed


Forgot your password?

Slashdot videos: Now with more Slashdot!

  • View

  • Discuss

  • Share

We've improved Slashdot's video section; now you can view our video interviews, product close-ups and site visits with all the usual Slashdot options to comment, share, etc. No more walled garden! It's a work in progress -- we hope you'll check it out (Learn more about the recent updates).


Comment: Re:The Level of Abstraction (Score 1) 158

by Art3x (#49177795) Attached to: Invented-Here Syndrome

It amazes me how many people don't get this, and want to write a PHP "Front Controller" that uses a querystring parameter to select the "page", and then slap a mod_rewrite rule on top to clean up the URL. Instead of—as it sounds like you discovered—putting each page in its own file in the filesystem and letting Apache "route" the request.

Right. I split the program into more files, instead of mod-rewriting everything through a gigantic PHP controller. Of course any database-backed app must eventually resort to the query string, PATH_INFO, or something. I usually use those to specify just the record ID or search filter, not an app section. Each section gets its own file.

Comment: Narrow Subject (Score 1) 244

by Art3x (#49177469) Attached to: Study: Refactoring Doesn't Improve Code Quality

The study was over a single application. From the article:

The researchers selected a small-scale application (about 4,500 lines of C# code) used by the academic staff at the University of Kelaniya for scheduling events and managing online documents for evaluation. 10 common refactoring techniques were applied to the code (e.g., Replace Type Code with Subclasses, Replace Conditional with Polymorphism).

Not only did they study just one application, but they limited refactoring to these 10 fancy techniques specific to object-oriented programming (from the research paper itself):

R1- Introduce Local Extension
R2- Duplicate Observed Data
R3- Replace Type Code with Subclasses
R4- Replace Type Code with State/Strategy
R5- Replace Conditional with Polymorphism
R6- Introduce Null Object
R7- Extract Subclass
R8- Extract Interface
R9- Form Template Method
R10- Push Down Method

In contrast, here are some things I do when refactoring:

- escape HTML in variables before embedding them in HTML, to seal against scripting attacks
- rewrite database queries to use parameters, instead of variables directly from user input, to seal against SQL injection
- move repeated code into functions
- Make app use just one database connection library instead of two. Yes, that's right, the app made two connections to the same database, through two different PHP libraries, on the same page. The only reason I can guess is that the last programmer meant to move from one library to the other, but left the company when he was right in the middle of doing so.

and a dozen other basic programming techniques. You had better believe that such refactoring improved code quality. Typically the code shrinks down to 30-70% its original size. Often it runs several times faster. For sure it is safer. And having merged code that was copy and pasted all over the palce, it is a lot easier to make changes to thereafter.

Theoretically, I shouldn't have to do these kinds of things, because a professional programmer should not strew such code behind them. But every single one of my fellow programmers or forebears here has committed these atrocities. For what it's worth, I work on a corporate intranet. So I probably see worse acts than at companies dedicated to software.

Comment: The Level of Abstraction (Score 5, Interesting) 158

by Art3x (#49148175) Attached to: Invented-Here Syndrome

You will always have to write some code of your own. Even if you use a CodeIgniter, AngularJS, and every prewritten function on StackExchange, still, you will have to write some code to configure the frameworks and to pull it all together.

You will always use some of someone else's code, too. Aren't you using Linux or something? You didn't write your own OS, did you? You're using a database, like MySQL or PostgreSQL or something, right? You didn't write your own database system, did you? And are you using a web server like Apache or Nginx?

So the question is not, should I write my own code or use someone else's. The question is where to draw the line.

I'm a web programmer, your typical LAMP developer (well, LAPP --- I use PostgreSQL). Like many PHP programmers, I first concentrated too much on the PHP. PHP is not the best language, as many have said, but I don't think it's quite as bad as people make it out to be. Anyway, I never took up any of the PHP frameworks. They seemed like too much trouble to adapt. (I should point out that I started with an intranet with a dozen or so applications already built.) I would research PHP frameworks from time to time, but always rejected them all, and felt a little self-doubt in doing so: "Do I suffer from Not-Invented-Here Syndrome?"

But PHP, and scripting languages in general, provide the right level of abstraction, I think. It takes care of memory management. It provides a bunch of functions for HTTP. It has its own templating syntax. It's great if you don't overuse it. In other words, in the MVC pattern, PHP does great for the View and, together with Apache, the Controller. But if you write a lot of your Model in PHP, with all this data processing, checking, calculations, etc. --- well, that's what the database is for, I think.

So, instead of eventually adopting a PHP framework, I learned more and more about Apache and PostgreSQL, and I learned that a lot of the things that I was doing in PHP could be done in SQL or in the Apache configuration, with a lot less typing (a lot more reading but a lot less typing). While most people are busy trying figure out how to write the practically all of the MVC in PHP, I realized that Apache was part of the Controller, PostgreSQL was part of the Model, and the browser was part of the View. I use PHP just to help them out, only when needed.

Comment: Re:Here's what I know, just because you're an EE (Score 1) 323

Since you already said about, you can even just leave it out: I wouldn't feel too anxious about that, especially web programming.

Maybe not, now that I look back at it.

For is another word that would work: I wouldn't feel too anxious about that, especially for web programming.

With or in are probably best, though.

Comment: Re:Here's what I know, just because you're an EE (Score 1) 323

These are prepositions, any words that can fill in the blank in the sentence The squirrel ran ____ the tree, more or less: Up, down, around, about, in, out, to, from, off, and so on.

Conquerors and rich people mixed Latin and Greek into Anglo-Saxon way back when. There is no difference in meaning between, for example, get and obtain, any more than if I began saying the Spanish gato instead of cat. So we have lots of words that mean the same thing.

Respect is Latin, meaning look back. So when you say:

So I wouldn't feel too anxious about that, especially w.r.t. web programming.

you mean I wouldn't feel too anxious about that, especially looking back at web programming or looking at web programming or thinking about web programming. Even other pure English prepositions, like with or in, would work: I wouldn't feel too anxious about that, especially with web programming or especially in web programming. Since you already said about, you can even just leave it out: I wouldn't feel too anxious about that, especially web programming.

Are they not interchangeable? Could you have said I wouldn't feel too anxious w.r.t. that, especially w.r.t. web programming?

Comment: Re:UX (Score 1) 323

I think this misses the gist of his complaint, which was:

sites that require Javascript to perform even the simplest thing, like ButtonPress or to display the main article text

Note he said, "even the simplest thing." He means simple things, like showing the text of the article, just as he said. And though he also mentions something interactive, like pressing a button, I agree with him that simple things like sign-in forms and the button at the bottom of the form to submit it should be straight HTML submit buttons. Sure, decorate it with CSS, and check the whole form with JavaScript so that the user need not meet a big error page afterward and have to go back and type it all again.

You say:

To have any level of quality in the code delivering a web app, even a 'simple' one, you're going to have to use an html5 browser with javascript enabled.

If I take your sentence literally, it's false at every turn.

Later you say:

When I select 20 items to be removed, I don't have to wait for 20 page reloads on a slow connection.

Checkboxes. Delete button.

And you mention a "slow connection." Few people have a slow connection anymore. But a slow connection will hurt an AJAX app worse than a single-transaction form that you fill out and then submit. On a non-AJAX form, checking boxes will still be instantaneous. On an AJAX form, clicking each delete link will seem sluggish. It's only on submit that the HTML form would seem slow.

Don't get me wrong. JavaScript is fine and can make things a lot better for the user, like field checking. Even AJAX is helpful in a lot of cases. But what the parent seemed to be saying, and what I agree with, is that on many sites all that extra stuff has made pages slower and flakier.

Comment: Yes, you can! (Score 1) 323

From the original post:

In my experience, web development is a cocktail of competing programming languages, frameworks and standards. Rarely a developer gets exposed to a single technology for a substantial period to learn it inside-out. Even still, in web development world, deep in-depth knowledge in anything will be outdated in few years' time as new technologies roll out. So, what matter's today? Knowledge on a particular technology or re-usable engineering skills ?

Yes, even in Web development, you can spend years using the same stuff. Many developers do, especially those writing in-house web apps at big companies. I've spent ten years in the IT department for a hospital group, and I've been slowly refining my skills with the same everyday tools since Day 1: Linux, PostgreSQL, Apache, PHP, HTML 4, CSS, and JavaScript. SQL gives me the most mileage, and it's the oldest. As I move what code I can from PHP to SQL, it shrinks, speeds up, and covers more situations.

I've never taken any classes in engineering or computer science. I've heard mixed opinions on their usefulness. My background in English, especially composition, helps me everyday. I recommend The Elements of Style, On Writing Well, and The Mac Is Not a Typewriter.

Human resources are human first, and resources second. -- J. Garbers