Code Comparing Issues

These are various issues that may come up when comparing code examples, such as the same scenario written in different languages/paradigms.


Counting libraries and Other Low-Level Operations

(Moved/copied from ProceduralMethodologies. May require editing clean-up)

And while it "is not realistic to build modules from scratch" whatever, I don't care - I don't expect you to build it from scratch. But if you include chart-drawing modules, YOU NEED TO COUNT THE PARADIGMS AND LOC USED IN THAT MODULE, otherwise you are "cheating" when you're saying "which paradigms your solution uses". Your 'solution' and which 'paradigms' it uses is the whole package, not just the little piece you want to count. Just counting the little pieces you want to count is the very definition of cherry-picking.

Usually one uses off-the-shelf tools to generate [charts] because it is rarely economical to roll your own (Although I've done it before), and often one cannot count the lines of code because it is proprietary and compiled/encrypted. I don't know what metric you use to claim "better" anyhow. You need to be clear what you find better, why its better, and how you are measuring. I cannot do that for you because I don't share your betterment feeling. If most purchase components to do charting, why do you want to include it in YOUR comparison? Something smells fishy here. I don't expect one to count the code needed to execute a Print statement under the cover, so why should charting be any different? --top

You can't excuse your cherry-picking by saying the data you need is inaccessible. Imagine a situation where you "purchased a component to do charting" where all you had to do was feed it the raw data and a basic description of the report you wanted and out pops HTML and PNG... i.e. exactly what your product is supposed to do. Then you can say, "hey! look at my procedural solution! it takes data, and passes it (unprocessed) straight to this other component, and out pops a report!". What did you prove about procedural? Exactly nothing. If you wish to be scientific, you are responsible for counting up everything in your solution that lies between receiving the report specification and outputting the HTML file. And why should charting be included in the comparison? Because the charts are part of many reports, and HTML - the output format YOU chose - lacks higher-level support for chart descriptions. Technically, you should include the 'Print' statement, too, if you 'Print' to the HTML file; it is also between receipt of the report specification and output of the report.

As proposed in ChallengeSixVersusFpDiscussion, perhaps fat libraries are the key to productivity, not newfangled paradigms. And you haven't addressed the Print statement issue, and all the assembler inside the compiler/interpreter, etc. Where is the point where we stop counting?

You seem to want the entire world to build you a super-library so that you can do anything you want by invoking a procedure. Your ignoring of the magic behind the curtain is the source of your cherry-picking. And I did address the 'Print' statement... see the last sentence of the prior statement. EVERYTHING in the process between receipt of report specification and output of the report should be counted. The 'magic' in the interpreter should be counted, too. It is also part of the 'business process... delivering'.


Another take:

The discussion above relates to a challenge between OO and Procedural that was issued largely between top and someone other than myself in the discussion on ProceduralMethodologies. It is my impression that Top feels he doesn't need to count the code he doesn't see, and that he feels it is simultaneously legal to answer a procedural challenge by cobbling together a bunch of off-the-shelf tools to do the job.

I readily commend using tools to do the job in a true business scenario, but I strongly believe that it is a horribly inappropriate response to a challenge. It's rather like claiming that 'BourneAgainShell' can beat many languages in the ComputerLanguageBenchmarksGame simply by passing its parameters to the highest-ranked solution.

If you are ComparingCode or methodologies, the right thing to do is make sure that both pieces of code solve the same problem. And if one solution does so by cobbling together other pieces of code (existing libraries, processes, partial solutions, etc.) then those other pieces of code must also be counted in the comparison in order to have the whole set of code that is 'solving the same problem'. That is, of course, supposing such solutions aren't blatantly violating the 'rules' of a fair 'challenge', which should disqualify them entirely. Does that mean low-level code underlying things like 'Print', too? Yes. Of course it does, if your solution does any 'Print'-ing. If you wish you could change the rules of the challenge a bit to exclude code for a particular set of pseudo-code level operations (and it wouldn't be unusual to do so for 'Print' or at least an unformatted 'file-write <filename> <string>'), but any such selection of operations that needn't be counted will be finite and limited. You don't get to add to the set a magic 'SolveThisProblem <inputs>'.

I believe Top is 'cheating' when he lauds praises upon ProceduralMethodologies when what he is actually doing is writing glue-code for other partial-solutions. He shouldn't be praising 'P/R' for that. He should be praising 'ToolCombinationApproach' or some other lamely named methodology that can fit in alongside his 'FeatureBuffetModel' et al. In that case, it becomes plain that his solution has a major weakness: it provides very few answers for solving the problems when a solution doesn't already exist. However, it also has its strengths, such as reasonable cost for industry-strength solutions. If he wishes, he can then go on to argue that 'Procedural' is better than all alternatives at glue-code (a dubious claim at best). But it isn't the same as arguing that procedural is better at 'custom biz apps' (whatever that means).

In the challenge above, top's job is to provide a procedural/relational solution to creating nested reports (in HTML) given some declarative specification of the report as input (which would depend upon the other guy's, since he told the OO guy to go first). If the report-spec involves diagrams with nestable charts and sub-diagrams, as I suggested, then top's solution (to solve the same problem) would need to also write diagrams with nestable charts and sub-diagrams. It would, I believe, provide a clear challenge where OO comes out 'ahead' of the procedural solution by most measures one would care to make, though I'm leaving the proof to the challengers.

But if top chooses to grab a bunch of charting software and ignore the paradigm it uses, that solution strikes me as remarkably similar to the bash-script in the ComputerLanguageShootout?. If top wanted to be a real winner, he could even do exactly that: take the other challenger's solution, write a 'procedural' bash script that calls it, and call the job done! Look! Procedural does the job in one line! Never mind the code behind the curtain...

In fair code comparing challenge, you can't go grab somebody else's solution and say that your code solved the problem. That is, very plainly, 'cheating'.

--BlackHat

Again, the hypothetical task is to convince a rank-and-file custom biz developer of the benefits of OOP. The challenge is NOT systems software and packaged tools. I for one have not challenged those domains (SS and PT). Why would you demonstrate stuff that nobody seems to be challenging? You make it sound like I am trying to pull a trick/cheat here. But I am merely focusing on the practicalities of comparing based on what say a domain business owner would care about. --top

BlackHat disagrees. Rank-and-file custom biz developer already believes market hype about benefits of OOP, even though they shouldn't (at least not for the reasons it is hyped).

Anyhow, if your claim is that procedural is better when a solution already exists because procedural can call that solution, then why aren't you making that very clear every time you praise procedural? Here is your corrected script for the future: "Top: OO is bad. Procedural is better than OO when a solution already exists." Repeat ad nauseam.

I was hoping for coded sample of this so called "nested report" so that we don't have to make generalities. (BTW, I already provided PayrollExample with inspect-able code if you want something existing to dissect.) And I did not make a claim about procedural being better. It was an OO claim that sparked this all.

I'm not actually a promoter of OO, and plan to leave the 'nested report' challenge to the challenger, who isn't me. Encapsulation (via lexical closure and interface polymorphism) and runtime configuration of computation (e.g. test configurations, construction of runtime objects that represent calculations-to-be-performed or actions-to-be-executed) are the two things I consider of value about OO languages. The large set of OO methodologies, however, especially those regarding domain-based object models and inheritance, I consider to be deeply flawed in some very fundamental ways. Since I don't generally approve of OO, I don't attempt to defend it. But I do demand that attacks on it be fair, just as I would attacks on Relational or Procedural.


See Also: LinesOfCode, CodeChangeImpactAnalysis


DecemberZeroSeven

CategoryMetrics, CategoryExample


EditText of this page (last edited January 11, 2011) or FindPage with title or text search