Essay on Code Defactoring

Essay on Code Defactoring

Length: 777 words (2.2 double-spaced pages)

Rating: Better Essays

Open Document

Essay Preview

Refactoring is the process of making code more readable and amenable to change. It stands to reason, then, that defactoring must be its opposite. This has been my task for today.
Earlier this week, my code failed a review (what a surprise). The problem was with a certain construct I had used to make up for the fact that ECMAScript does not support access control with keywords like “private” or “public” as other languages do, but does so in a different way. His view is that access control is subversive, and I should rewrite it using .prototype, so that all the members are public, but make it clear by commentary, documentation, and/or some naming convention, that “private” ones are only to be used by objects of this class. I might add, this is not some subversive bit of trickery that I have invented completely off the top of my head, but one found in our bible on these matters.
Of my code, he “assumes that it will be slower” than his proposed rewrite. Not a wholly unreasonable assumption, but based on nothing other than guesses. This is almost a textbook example of Premature Optimisation, it is not some piece of core functionality that will be called 1000 times a second, this is code that is likely to be executed somewhere between 0 and about 20 times on startup, depending on inputs. The only thing that keeps it from being real premature optimisation is that premature optimisation at least shaves the odd nanosecond off execution times.
Quite reasonably (or so I thought), in his review comments, my nemesis said that I should feel free to disagree, and make a case for what I had done, and it can be looked at again. I did exactly that, posting my reply about half an hour after his initial review, I even ensure that words ...


... middle of paper ...


... summon up the enthusiasm to put it up for review, knowing that it’s going to fail.
“We shouldn’t be doing anything that we feel might have a performance cost”

a) I don’t feel it will, and I have been proven right.
b) When did that edict arrive? Most of our code seems to have been written with the express purpose of being as slow as possible. Tweaks like this, even if his guesses turned out to be correct would have negligible effect due to the general stupidity of the architecture (a future post in itself)
I was also chastised for doing this profiling, as, again, when you have a lot to do, the best way to make progress is to pluck random guesses out from where the sun doesn’t shine, implement them, and declare them a success. Gathering data so that you can work out where to target your efforts or measure your success, is, apparently, a massive waste of time.

Need Writing Help?

Get feedback on grammar, clarity, concision and logic instantly.

Check your paper »

The Chivalric Code of Medieval Knights Essay

- Today when people hear, “chivalry,” the modern idea connected with the word is romance. Many would picture a man holding a door open for a woman, or think of the phrase, “Chivalry is dead!” In reality, chivalry was a more so of a code of conduct, and the concept of it only being tied to romance is actually a very small part of it. This conduct was a mix between where the individual’s social status was, how knights dealt with treaties, and the glory, freedom, and respect that came with it. Two French rulers began this around the late eighth and early ninth century....   [tags: code of conduct]

Better Essays
989 words (2.8 pages)

Essay about The Expansion of Babylon and the Code of Hammurabi

- Laws play a major role in the expansion of a nation. Justice is the upholding of those laws from an impartial standpoint. King Hammurabi managed to organize one of the first best preserved set of laws from ancient Babylonian times. The Code of Hammurabi was recorded on clay tablets standing eight feet high. This consisted of 282 provisions arranged under a variety of subjects ranging from family and personal property to trade and business. These laws established penalties with the philosophy that the punishment should fit the crime....   [tags: Code of Hammurabi, laws, ]

Better Essays
1000 words (2.9 pages)

Essay about Quick Response Code

- A Quick response code known as a QR code is a type of 2D bar code which enables users to get access to information through a smartphone.This process is known as mobile tagging where the smartphone user points a at a QR code which opens a barcode reader application. The user then interprets the code which may contain various options such as an invitation to download a mobile application, a link to video or an SMS message or inviting the reader to respond to a poll. The Technology for QR codes was also developed by a Toyota subsidiary, Densa-Wave, which were initially used for tracking inventory (Rouse,2010)....   [tags: QR code]

Better Essays
836 words (2.4 pages)

Should Schools Enforce the Dress Code? Essay

- No matter what state you live in virtually everywhere schools have a uniform or dress code policy. In the last few years the percentage of schools requiring a uniform has gone up almost ten percent, making the total of public and private schools with a uniform policy at about 23 percent. But the real question is how many schools really enforce it. What do students and parents think of it. At Joy Christian School the dress code in the last year has dramatically changed, getting more and more lenient as the years go by because of students refusing to follow it....   [tags: uniform, polic, students, parents, code]

Better Essays
601 words (1.7 pages)

Code Of Hummurabi Essay

- History is the past, which for the most part can not be scientificately proven. The real; goal of History is to rediscover past. A dramatic error happens when past is rediscovered from our own bias that is from the way we see it. Even certain artifacts and works pf literature that we have left from earlier civilizations can be interpreted in several different ways, or misinterpreted to a certain extend or entirely. Usually interpretation or even misinterpretation is affected bu the concept of ethnocentrism, where different communities have an already set up establishment of certain norms based on their own believes, traditions, social, legislative, and personal values and ethics from whi...   [tags: Hummurabi Code of Law]

Free Essays
1491 words (4.3 pages)

Code Of Hummurabi Essays

- In his position as King of Babylonia, Hammurabi managed to organize the world's first code of laws and establish Babylon as the dominant and successful Amorite city of its time. "Records written on clay tablets show that Hammurabi was a very capable administrator and a successful warrior. His rule spanned from 1792 B.C. to 1750 B.C. When he became king in 1792, he was still young, but had already become entrusted with many official duties in his administration" (Grolier). In the early years of his reign, Hammurabi mostly participated in traditional activities, such as repairing buildings, digging canals, and fighting wars....   [tags: Hummurabi Code of Law]

Free Essays
562 words (1.6 pages)

Essay on The Code of Professional Conduct

- The Code of Professional Conduct The public affairs practice has many definitions one such definition is communicating with the public to create and sustain good mutual relations with a organisation or company. There are P.R. agents who work in-house and others which work for a agency where ever you work as a P.R. practitioner are certain codes of ethics you are asked to follow drawn up in the code of Lisbon drawn up in or the code of Athens drawn up im going to discuss the clause of the code of professional conduct drawn up by the public relations institute of Ireland on the 20th annual general meeting of the public relations institute of Ireland on the 8th dec 2003 these codes enhance th...   [tags: Business Ethics Code]

Free Essays
1479 words (4.2 pages)

A Code Hero in Hemingway's Books Essay

- A Code Hero in Hemingway's Books Robert Jordan has been defined as a Hemingway code hero. In Hemingway’s books, a code hero is usually male, as Hemingway’s books seem to have a similarity to Hemingway himself. These code heroes may have been previously wounded or gone through some sort of an ordeal, and so they could have a drinking problem, or a problem sleeping. They seem to be disillusioned, and/or self-oriented, and are not usually loyal to a large cause, but rather a small group of people or a relatively small idea or thing....   [tags: Code Hero Robert Jordan Essays]

Better Essays
602 words (1.7 pages)

Ray Bradbury's Da Vinci Code Essay

- In the Louvre, a monk of Opus Dei named Silas apprehends Jacques Saunière, the museum's curator, and demands to know where the Holy Grail is. After Saunière tells him, Silas shoots him and leaves him to die. However, Saunière has lied to Silas about the Grail's location. Realizing that he has only a few minutes to live and that he must pass on his important secret, Saunière paints a pentacle on his stomach with his own blood, draws a circle with his blood, and drags himself into the center of the circle, re-creating the position of Da Vinci's Vitruvian Man....   [tags: Da Vinci Code Bradbury]

Free Essays
1536 words (4.4 pages)

Dan Brown's The Da Vinci Code Essay

- Dan Brown's The Da Vinci Code Mel Gibson paid out twenty million of his own money to produce and direct the critically acclaimed movie Passions of the Christ, which depicts the Biblical account of Christ's crucifixion....   [tags: Dan Brown Da Vinci Code]

Free Essays
1104 words (3.2 pages)