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 »

Essay on The Code Of The Dress Code

- Envision yourself sauntering down the hallway when you see a teacher you despise inspect you from head to toe. You know they are just trying to find something wrong with what you are wearing so they can dress code you. Their face lights up, they got it. They walk toward you with a smug look on their face and utter the infamous words, “are you in dress code?” As Belleville East students we have all heard this question numerous times throughout the day. Whether this question was directed towards you, or your peers, this simple, but oh so annoying question, is asked countless times throughout the day....   [tags: Education, Dress code, Trousers, School uniform]

Better Essays
1533 words (4.4 pages)

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)

Conversational Uses Of Code Switching Essay

- Conversational Use of Code-Switching Introduction Most of us adjust the way we speak for the person or people we’re speaking to. This can be as subtle as speaking slowly for a child, or as obvious as switching to another language entirely. Depending on our situation or surroundings, we may change the way we express ourselves. The term for this is code-switching. Code switching is the practice of shifting between different languages or different ways of speaking or expressing yourself in a conversation with someone....   [tags: Linguistics, Language, Code-switching]

Better Essays
1086 words (3.1 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)

Essay on The Hammurabi Code And Mosaic Law

- The Hammurabi Code and Mosaic Law were used to lead their people during two different era. They were similarities and differences, between the two. For example, they were both discovered by their leaders in similar ways, but differed in their approach to justice and morality. Hammurabi Code respects women, but has distinct social class and penalties based on the class you belonged to, while the Mosaic Law had no distinction between people and gave everybody even fairness. Both the Hammurabi Code and the Mosaic Law were received by their peoples in similar ways....   [tags: Code of Hammurabi, Law, Babylonia, Babylon]

Better Essays
1266 words (3.6 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)