This is a great overview! Thanks for writing this up. I wonder if it's worth giving some more guidance about when to use #ifdef vs. say splitting out a couple of methods into a platform-specific file. For example: "if you find yourself wrapping the entire body of a function in platform #ifdefs, that may be a sign that it's time to refactor that method into separate per-platform source files; if you find yourself doing so for several methods of a class, it may be time for a helper or delegate class that encapsulates the platform-specific behavior" (example: the platform delegate that let us unfork test_shell_main.cc)."
My concern is that #ifdefs can be great for a "spot fix" here and there, but if they start growing, they can get unwieldy very quickly and obscure what code is actually getting run on any given platform. --Amanda On Fri, Jun 19, 2009 at 12:42 PM, Brett Wilson<bre...@chromium.org> wrote: > > Our team has had somewhat of an ad-hoc approach to organizing code > that's different across platforms. In many cases our approach has been > quite good. In others, less so, and there have also been questions > about what the preferred method for writing a certain component in a > cross-platform way. > > Last night Ben and I wrote a document that tries to clarify this. It's > a combination of what we're doing now that works well, and what we > probably should be doing: > http://dev.chromium.org/developers/design-documents/conventions-and-patterns-for-multi-platform-development > This is linked to from the "Engineering design documents" page. > > If you're starting a new component or reorganizing an existing one, > try to follow these guidelines. It can't possibly cover every case, so > you'll have to use your best judgement. > > Feedback from people who have done a lot of this stuff would be great. > Ideally it would be easy to follow and cover most cases for everybody. > > Thanks! > Brett > > > > --~--~---------~--~----~------------~-------~--~----~ Chromium Developers mailing list: chromium-dev@googlegroups.com View archives, change email options, or unsubscribe: http://groups.google.com/group/chromium-dev -~----------~----~----~----~------~----~------~--~---