Base is "done": please stop adding crap

16 views
Skip to first unread message

Brett Wilson

unread,
Jan 6, 2011, 1:59:42 PM1/6/11
to Chromium-dev
Executive summary:
- When adding new code, put it in the most specific location that
makes sense (usually not base).
- Avoid *_util files.

True story:

About 2 years ago somebody (I've forgotten who, which is good for
them) sent out a change to add a function to base/string_util. The
function was "interpret the input string in argument 1 as a series of
tokens separated by the character given in argument 2, and parse it as
key/value pairs, interpreting every-other-one as an integer, returning
the result in output argument 3 as a vector<pair<string, int>>". I
asked why they were adding such a crazy function to base, and they
said "so somebody can re-use this code."

The size of our code base is itself one of the largest impediments to
code re-use. Even if the function you want exists in string_util or in
some other file in base, you'll have a hard time finding it because of
all the other "useful" functions/files in the way. Taken to an
extreme, the entire browser should be in base because you should be
able to use it in different products.

The current code in base has supported a a very large stable browser
project for many years. It's exceedingly likely that if some concept
isn't already in base, it's not needed, and the team overall can
benefit from having a more focused list of core concepts. While there
will always be some exceptions, everybody's default position should be
to be skeptical of new functionality in base.

So where should you put your code? Put it in the most specific place
that makes sense. We can always move it later if it ends up being
really awesome.

- In your component's directory. Be realistic about the likelihood
that somebody in another component will want your functionality,
actually find your code (even if it's in base), and use your solution.
If the answer is "low", just put it in your directory.

- chrome/common (shared by the entire product) and chrome/browser
(browser process only).

- app. This is "base for windowed applications." Common code dealing
with the window manager, and clipboard, and user input/output goes
here. Try to avoid too-specific-stuff for the same reasons as for
base.

- base in an appropriate subdirectory. We've been adding more
categorization to make it easier to find stuff that really needs to be
shared across many projects.

- base in the root. Your code is so great everybody should be hit over
the head with it.

BUT base still needs a lot of cleanup and improvement, and this
doesn't mean we don't want changes. If you code really does clean up
different places across our codebase and you actually do this cleanup,
it's something we want shared as widely as possible.

Brett

David Levin

unread,
Jan 6, 2011, 2:28:43 PM1/6/11
to bre...@chromium.org, Chromium-dev
What recent addition triggered this? Are you planning to move things out of base? The "true story" which supports this is a strawman scenario.

Base looks like a framework of utility functions and classes. These grow over time as a code base develops new patterns and new ways of doing things. (Look at any framework as an example.) Stopping this seems to imply that things should not change to do things in new ways.

dave


--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
   http://groups.google.com/a/chromium.org/group/chromium-dev

Brett Wilson

unread,
Jan 6, 2011, 3:06:51 PM1/6/11
to David Levin, Chromium-dev
On Thu, Jan 6, 2011 at 11:28 AM, David Levin <le...@chromium.org> wrote:
> What recent addition triggered this? Are you planning to move things out of
> base?

I have moved about 100 files out of the root base directory in the
past month. Some of these went into subdirectories in base. Some have
gone into the other places I listed in the email. I've moved about
30-50 files out of base before that in the past year.

> The "true story" which supports this is a strawman scenario.

The story was intended to be an illuminating example rather than
justification for a change ("somebody did X two years ago so now we
have a new rule Y."). I think this was pretty clear.

> Base looks like a framework of utility functions and classes. These grow
> over time as a code base develops new patterns and new ways of doing things.
> (Look at any framework as an example.) Stopping this seems to imply that
> things should not change to do things in new ways.

Any good framework provides some limits on the types of things that
you can do or they would explode. STL provides generic ways of
expressing new types of algorithms and containers and doesn't add
every kind of random crap that people propose. New stuff gets added
only when its generally useful to a large number of applications. This
is the model I (fairly clearly, I think) explained.

Brett

Ben Goodger (Google)

unread,
Jan 6, 2011, 3:16:40 PM1/6/11
to bre...@chromium.org, Chromium-dev
On Thu, Jan 6, 2011 at 10:59 AM, Brett Wilson <bre...@chromium.org> wrote:
- app. This is "base for windowed applications." Common code dealing
with the window manager, and clipboard, and user input/output goes
here. Try to avoid too-specific-stuff for the same reasons as for
base.

I'm going to add that app is going to go away very quickly (over the next week). I am moving its contents into a more focused "ui" directory. The intent of this directory is for application support needed to build a ui application. It is not a general dumping ground. (Well maybe I can move all the UI-specific bits out of src/app into src/ui and it can remain a  dumping ground, but I think dumping grounds are a bad idea :-)

-Ben

David Levin

unread,
Jan 6, 2011, 3:57:40 PM1/6/11
to Brett Wilson, Chromium-dev
I understand now and that makes sense. I read "crap" as stuff not as crap. :)

The subject is slightly misleading 'Base is "done"' which is what led to my misunderstanding. I believe understand that too (largely done and the bar is high for adding things there because low hanging fruit has been done).

Dave

Brett Wilson

unread,
Jan 6, 2011, 4:17:52 PM1/6/11
to David Levin, Chromium-dev
On Thu, Jan 6, 2011 at 12:57 PM, David Levin <le...@chromium.org> wrote:
> I understand now and that makes sense. I read "crap" as stuff not as crap.
> :)
> The subject is slightly misleading 'Base is "done"' which is what led to my
> misunderstanding. I believe understand that too (largely done and the bar is
> high for adding things there because low hanging fruit has been done).

I purposely used an inflammatory subject line so people would read my email :)

Brett

James Robinson

unread,
Jan 6, 2011, 4:32:19 PM1/6/11
to bre...@chromium.org, David Levin, Chromium-dev
Perhaps "Base is full"?

- James

Brett Wilson

unread,
Jan 6, 2011, 4:47:27 PM1/6/11
to Chromium-dev
On Thu, Jan 6, 2011 at 10:59 AM, Brett Wilson <bre...@chromium.org> wrote:

I forgot to mention the _util files. When possible, please file the
most specific place to put your code, and use the most specific name
possible. Historically we've had a number of foo_util files which are
a dumping ground for lots of random stuff related to foo (string_util,
win_util, etc.). If you really have some random crap, try to make a
specific util file rather than a general one. Example: the stuff
converting strings to numbers was split off iof string_util nto
string_number_conversions.h, and the stuff dealing with HWND was moved
from win_util to hwnd_util.

Brett

Reply all
Reply to author
Forward
0 new messages