Beware the Share

Beware the Share

Udi Dahan

iT WAS MY FiRST PROjECT AT THE COMPANY. I’d just finished my degree and was anxious to prove myself, staying late every day going through the existing code. As I worked through my first feature, I took extra care to put in place everything I had learned—commenting, logging, pulling out shared code into libraries where possible, the works. The code review that I had felt so ready for came as a rude awakening—reuse was frowned upon!

How could this be? Throughout college, reuse was held up as the epitome of quality software engineering. All the articles I had read, the textbooks, the seasoned software professionals who taught me—was it all wrong?

It turns out that I was missing something critical.

Context.

The fact that two wildly different parts of the system performed some logic in the same way meant less than I thought. Up until I had pulled out those libraries of shared code, these parts were not dependent on each other. Each could evolve independently. Each could change its logic to suit the needs of the system’s changing business environment. Those four lines of similar code were accidental—a temporal anomaly, a coincidence. That is, until I came along.

??14 97 Things Every Programmer Should Know

?

???????????????The libraries of shared code I created tied the shoelaces of each foot to the other. Steps by one business domain could not be made without first synchro- nizing with the other. Maintenance costs in those independent functions used to be negligible, but the common library required an order of magnitude more testing.

While I’d decreased the absolute number of lines of code in the system, I had increased the number of dependencies. The context of these dependencies is critical—had they been localized, the sharing may have been justified and had some positive value. When these dependencies aren’t held in check, their ten- drils entangle the larger concerns of the system, even though the code itself looks just fine.

These mistakes are insidious in that, at their core, they sound like a good idea. When applied in the right context, these techniques are valuable. In the wrong context, they increase cost rather than value. When coming into an existing codebase with no knowledge of where the various parts will be used, I’m much more careful these days about what is shared.

Beware the share. Check your context. Only then, proceed.

时间: 2024-10-06 17:08:53

Beware the Share的相关文章

Web Share API的解释(译)

原文地址:https://github.com/WICG/web-share/blob/master/docs/explainer.md  Web Share是一个提议阶段的Web API,用于将网站的数据(文本.URL或图片等)分享到任意的目标应用,比如系统服务.本地APP或其它网站.开发者可以创建一个通用的分享按钮,当用户点击时就可以触发一次系统分享的会话. Web Share所属的投石机项目(Ballista project)是Chromium的子项目,该项目致力于打通网站与网站.网站与本

Can you share some Scala List class examples?

Scala List FAQ: Can you share some Scala List class examples? The Scala List class may be the most commonly used data structure in Scala applications. Therefore, it's very helpful to know how create lists, merge lists, select items from lists, operat

Share data between VSTO and Excel DNA App domains

Is there a way to share data between a VSTO add in and an Excel DNA add in? Or can the Excel DNA add in be loaded into the VSTO's app domain? The Excel-DNA add-in will always be in a separate AppDomain. You might try to pass an object via the AddIn's

尝试在virtualbox fedora21 下安装additions和mount share folder

安装这个additions的过程,基本上可以参照 http://gamblisfx.com/how-to-install-virtualbox-guest-additions-on-fedora-21/ 拷贝一份过来就是, 1. 先更新内核 yum update kernel* 2. 重启 reboot 3. 安装kernel headers等 这一步很关键,因为之前好几次都是在这里失败了.没有看到这篇文章之前,估计是少了dkms(虽然我其实没有搞懂这个是什么),但是它works. yum in

Android Studio Share Project On Github

在Android Studio上将项目导入Github上: 1. 创建一个Project,点击VCS -> Enable Version Control Integration... 2.选择Git,点击OK 3. VCS -> Import into Version Control -> Share Project on Github 4. 在弹出的对话框里登录GitHub账号密码 5.登录成功后,弹出对话框,可以对即将导入到Github的项目进行描述 6.确认后,Add Files

retrying with upper case share name mount error 6 = No such device or address

今天想把windows下的资料共享给Linux系统用,日了,安装了samba之后,老是提示如图 气的牙疼,后来把用户名和密码加上之后就OK了. retrying with upper case share name mount error 6 = No such device or address,布布扣,bubuko.com

Oracle Share Pool内部管理机制

SHARE POOL利用堆(HEAP)的内存管理方式管理,在物理上由多个内存区(EXTENT)组成,内存区又由多个不同大小的CHUNK组成.而CHUNK又有可重用和空闲之分,并且它们分别有LRU LIST.FREE LIST.RESERVED LIST串联起来. 堆管理 Shared Pool是利用堆内存管理方式管理的(KGH:Kernel Generic Heap).从Oracle 9i开始,可以有多个最高级堆(TOP-LEVLE HEAP),最高级堆可以分成多个副堆,副堆下面还拥有子堆.堆和

Share Point 创建 TimerJob

public class SyncMetadataJob:SPJobDefinition { private const string JobName = @"Metadata Sync Job"; private int counter = 0; public SyncMetadataJob() : base() { } public SyncMetadataJob(string jobName, SPService service) : base(jobName, service,

openstack安装配置—— file share node 配置

实际生产中,很多时候需要数据源的共享来实现多节点的实时数据保持一致,openstack官方提供了manila服务模块实现了云盘共享,manila服务也是需要manila服务端和存储节点共同组成的,本实验中为了节约虚机节点,就把manila服务端安装在了controller节点上,manila数据存储节点和cinder存储节点合并使用一个虚机节点,各自使用了一块独立硬盘. manila服务端配置 准备数据库 [[email protected] ~]# mysql Welcome to the M