时间:北京时间2011年6月22日(周三)晚19:30-20:30
演讲人:
Martin Reddy,苏格兰人,计算机科学博士,Code Reddy公司的创始人和CEO,曾在Pixar、Linden Lab和SRI International等公司担任软件工程师和架构师,发表过40篇文章,拥有3项专利,出版过两本书:《Level of Detail for 3D Graphics》和《API Design for C++》。
文字记录:
(19:13:08)lidachun与所有人说:API涉及到Web service的设计吗?
(19:13:24)*十一月的雨与所有人说:不是问c++吗。
(19:14:52)[umlchina]与*MartinReddy说:Martin, lidachun's question: Is web service design same to API design?
(19:16:37)*十一月的雨与所有人说:what's the difference with design pattern and API design
(19:16:40)*MartinReddy与所有人说:I would say that "API Design" is a more general term
(19:16:58)*MartinReddy与所有人说:where an API design can be implemented in C++, Java, Python, etc.
(19:17:06)*MartinReddy与所有人说:And also as a web service that you access over http
(19:17:19)*MartinReddy与所有人说:Web services are a hot topic right now
(19:17:31)*MartinReddy与所有人说:So many people use the term "API design" to refer to web services
(19:17:48)*MartinReddy与所有人说:But I try to be specific in such cases by saying "Web API Design"
(19:18:24)lidachun与*十一月的雨说:Think Martin!
(19:18:36)lidachun与所有人说:Think Martin!
(19:18:42)*十一月的雨与所有人说:i don
(19:18:53)*十一月的雨与所有人说:i do not understand what's the api design
(19:19:21)*十一月的雨与所有人说:is it like Process-oriented programming
(19:19:27)*MartinReddy与所有人说:API Design is simply defining an interface to a piece of software that is used by other users/progra
(19:20:08)*MartinReddy与所有人说:For example, in C++, you can use the Standard Template Library, or STL
(19:20:18)*MartinReddy与所有人说:to access things like std::string or std::vector
(19:20:38)*MartinReddy与所有人说:The public functions for std::string are its API
(19:20:51)*十一月的雨与所有人说:it sounds like interface-oriented programming
(19:20:56)*MartinReddy与所有人说:It says how a user can interact with that object
(19:21:09)*MartinReddy与所有人说:Yes, interface-oriented programming is basically another word for it
(19:21:23)*MartinReddy与所有人说:There are many different words for API design
(19:21:35)*MartinReddy与所有人说:And there are many terms that imply the need for API design too
(19:21:56)*十一月的雨与所有人说:it also like facade design pattern
(19:22:14)*MartinReddy与所有人说:such as modular development, code reuse, componentization, DLL, etc.
(19:22:33)*MartinReddy与所有人说:Well, a facade design pattern is a specific design pattern
(19:22:40)*MartinReddy与所有人说:And one way to build an API
(19:22:50)*MartinReddy与所有人说:But there are many other design patters that you can use to build an API too
(19:23:10)*MartinReddy与所有人说:A facade is particularly useful if you have a lot of legacy code with any good interface
(19:23:26)*MartinReddy与所有人说:and you want to create a new API (a facade) around that old legacy code
(19:23:36)*十一月的雨与所有人说:but i think this is have not especially with other progamming
(19:23:39)*MartinReddy与所有人说:But of course you can write a new API from scratch too
(19:24:15)*MartinReddy与所有人说:Correct - if you're creating a facade, you are creating an API
(19:25:14)*MartinReddy与所有人说:The important aspect of an API is that you present a logical interface to your code
(19:25:23)*MartinReddy与所有人说:but do not expose any of the internal private details
(19:25:41)*MartinReddy与所有人说:That's essentially what a facade tries to do:
(19:25:51)*MartinReddy与所有人说:wraps a new interface around some existing code
(19:27:39)*十一月的雨与所有人说:ok, good
(19:29:31)[umlchina]与*MartinReddy说:Qeustion from Zhang Chunping: Any design patterns on API design besides 23 GOF patterns?
(19:31:12)*MartinReddy与所有人说:That's a good question
(19:31:42)*MartinReddy与所有人说:Some of the GOF patterns can be applied more to your implementation, rather than your interface
(19:32:08)*MartinReddy与所有人说:For example, a Facade or Proxy is clearly providing an API: a public interface
(19:32:27)*MartinReddy与所有人说:But perhaps you might want to hide your use of Singleton as an implementation detail
(19:32:39)*MartinReddy与所有人说:So some GOF patterns are more applicable to API Design that others
(19:32:56)*MartinReddy与所有人说:Also there are other patterns or idioms that can be applied to API Design
(19:33:05)*MartinReddy与所有人说:For example, the Pimpl Idiom in C++
(19:33:45)*MartinReddy与所有人说:Or Named Parameter Idom (NPI) as an alternative to functions with lots of parameters
(19:34:45)*十一月的雨与所有人说:great
(19:34:54)lidachun与所有人说:C++ 设计的API接口能否适用于其他语言,这样的设计更有通用性
(19:34:58)[umlchina]与*MartinReddy说:Tian Shengjun's question: Which type of class is better on api design, pure vitual class or entity c
(19:35:09)[umlchina]与*MartinReddy说:pure vitual class or entity class(what he mean may be concrete class) ?
(19:35:37)*MartinReddy与所有人说:Well, I think it depends on what you are trying to design
(19:36:01)*MartinReddy与所有人说:For example, you will use a pure virtual function to create an "interface"
(19:36:16)*MartinReddy与所有人说:(as in the Java sense of interface)
(19:36:56)*MartinReddy与所有人说:I often advocate avoiding using virtual until you know you want users to inherit
(19:37:14)*MartinReddy与所有人说:Because creating a virtual exposes a lot more of your class's internal details
(19:37:38)*MartinReddy与所有人说:There is a tension here between creating a design that is very extensible by your users
(19:37:53)*MartinReddy与所有人说:But also exposes too much internal details
(19:38:19)*MartinReddy与所有人说:I don't think there's a hard and fast rule, but I prefer to avoid exposing internal details until
(19:38:26)*MartinReddy与所有人说:absolutely necessary
(19:39:16)*MartinReddy与所有人说:(How about I write "END" when I'm done with my answers so you know when I'm done?)
(19:39:18)*MartinReddy与所有人说:END
(19:40:04)[umlchina]与*MartinReddy说:Thank you
(19:40:27)*十一月的雨与所有人说:thanks for your great ansowers
(19:40:37)*MartinReddy与所有人说:You're welcome!
(19:41:26)*MartinReddy与所有人说:There were some questions earlier about what an API is. Perhaps I could quickly address that
(19:41:53)*MartinReddy与所有人说:I see an API is simply: code that other users (or programs) have to use
(19:42:21)*MartinReddy与所有人说:An API is the abstract description of the interface:
(19:42:28)[umlchina]与*MartinReddy说:Li Wenjun's question: how can I get good interface, from use case specification (top to bottom) or f
(19:42:34)*MartinReddy与所有人说:i.e., the function calls, enums, types, consts etc.
(19:42:42)[umlchina]与*MartinReddy说:(top to bottom) or from existing classes (bottom to top)?
(19:43:01)*MartinReddy与所有人说:And these can by implemented in a library that you link into your programs
(19:44:14)*MartinReddy与所有人说:Li Wenjun: my own preference is to gather requirements from the users
(19:44:37)*MartinReddy与所有人说:and then to try to extract the key concepts - the major classes - from that information
(19:44:54)*MartinReddy与所有人说:then to work out how these major classes relate to each other
(19:45:19)*MartinReddy与所有人说:So, my preference, is to try and work out the coarse, high-level architecture first
(19:45:48)*MartinReddy与所有人说:from there you can dive down to specific classes
(19:46:11)*MartinReddy与所有人说:but only to the level that you want to - i.e., you don't have to design every class
(19:46:42)*MartinReddy与所有人说:I then prefer to add more detail in an interative (agile) approach
(19:47:00)*MartinReddy与所有人说:but I think it's important for everyone on a team to have a shared high-level architecture
(19:47:11)*MartinReddy与所有人说:in their heads before starting on an agile iteration
(19:47:17)*MartinReddy与所有人说:END
(19:48:43)*十一月的雨与所有人说:good
(19:49:18)*十一月的雨与所有人说:uml china 会把聊天内容记录下来,发给大家吗?
(19:49:38)[umlchina]与*MartinReddy说:Ouyang Jiexiao's question: I am interested in your experience in Pixar and Linden Lab, How were you
(19:49:51)[umlchina]与*MartinReddy说:Linden Lab, How were you feeling there? How are the development process in them?
(19:50:02)[umlchina]与*十一月的雨说:会的
(19:50:25)*MartinReddy与所有人说:Ouyang Jiexiao: Yes, great question. Every company I have worked in has been very different.
(19:50:44)*MartinReddy与所有人说:At Pixar, we had a very large code base that was over 25 years old
(19:51:13)*MartinReddy与所有人说:The code had devolved somewhat, so that it was difficult to make major changes
(19:51:35)*MartinReddy与所有人说:We therefore decided to build a new film-making system to replace the old one
(19:52:03)*MartinReddy与所有人说:To do this, we tried to adopt good software development processes
(19:52:27)*MartinReddy与所有人说:We had a design team (called Object Modeling) who was responsible for creating the architecture
(19:52:44)*MartinReddy与所有人说:and class designs, and communicating those to everyone
(19:53:07)*MartinReddy与所有人说:We had a large QA team because we placed a big focus on writing automated tests
(19:53:28)*MartinReddy与所有人说:We required all core (non-GUI) code to have 100% line coverage by unit tests
(19:53:53)*MartinReddy与所有人说:We also had a UI design team and documentation team to provide good user experience
(19:54:21)*MartinReddy与所有人说:In terms of engineering, we adopted some agile techniques, but we were still quite heavy processwise
(19:54:37)*MartinReddy与所有人说:For example, we developed a lot of requirements documents
(19:54:57)*MartinReddy与所有人说:In contrast, at Linden Lab, the team embraced agile a lot
(19:55:08)*MartinReddy与所有人说:At Linden, we used SCRUM
(19:55:39)*MartinReddy与所有人说:So we would collect user stories, define our backlog, prioritize and bid out our iterations
(19:55:55)*MartinReddy与所有人说:and try to stick to 2-week iterations (at Pixar, it was more like 2 months)
(19:56:24)*MartinReddy与所有人说:I learned to like SCRUM a lot - although there are things you have to be aware of when using SCRUM
(19:57:02)*MartinReddy与所有人说:I'm happy to chat more about any of those development techniques/processes if you like
(19:57:13)*MartinReddy与所有人说:END
(19:58:11)[umlchina]与*MartinReddy说:Liu Minye's question: In our company, all developers are busy on their own project, no one would do
(19:58:41)[umlchina]与*MartinReddy说:no one would do more work on better API or other reusable things. How to change such situation
(19:59:04)*MartinReddy与所有人说:Liu Minye: I see this a lot
(19:59:32)*MartinReddy与所有人说:For example, when Linden Lab was a small company developers were told
(19:59:39)*MartinReddy与所有人说:to "do what you want"
(19:59:54)*MartinReddy与所有人说:this can be a good thing when you have a small team of talented engineers
(20:00:04)*MartinReddy与所有人说:you are basically saying that you trust them to make good decisions
(20:00:17)*MartinReddy与所有人说:However, over time, this can turn out to be a bad thing
(20:00:34)*MartinReddy与所有人说:For example, the Second Life client eventually became very difficult to use
(20:00:49)*MartinReddy与所有人说:with lots of options and features, some options that conflicted with each other,
(20:01:06)*MartinReddy与所有人说:We reached the point where we had to step back and look at the produt as a whole
(20:01:20)*MartinReddy与所有人说:and come up with a unified vision for how it was supposed to work
(20:01:36)*MartinReddy与所有人说:To remove features that didn't make sense or combine similar features
(20:01:54)*MartinReddy与所有人说:Unfortunately, many companies only adapt after they realize that things have gotten very bad
(20:02:16)*MartinReddy与所有人说:It can be difficult to realize ahead of time and make changes to avoid these problems
(20:02:27)*MartinReddy与所有人说:One big thing for me is communication
(20:02:49)*MartinReddy与所有人说:When a team is very small, you can just talk to the person sitting next to you
(20:03:01)*MartinReddy与所有人说:But when a team grows, the communication channels have to evolve too
(20:03:22)*MartinReddy与所有人说:This might mean more documentation or more meetings or more e-mail
(20:03:36)*MartinReddy与所有人说:None of which is very fun, but if you don't fix your communication channels
(20:03:56)*MartinReddy与所有人说:then developers don't know what everyone else is doing and you get into problems
(20:04:02)*MartinReddy与所有人说:So, to answer your question:
(20:04:28)*MartinReddy与所有人说:The management has to agree that developers should work to a unified vision
(20:04:43)*MartinReddy与所有人说:And the communication channels have to allow developers to know what else is going on
(20:04:59)*MartinReddy与所有人说:As an example, at Pixar, we held "Weeklies"
(20:05:18)*MartinReddy与所有人说:which was a meeting where the entire team (dev, QA, design, doc, etc.) go together
(20:05:28)*MartinReddy与所有人说:and engineers would demonstrate things they had been working on
(20:05:44)*MartinReddy与所有人说:this was a great way to communicate new changes and often caused people to start
(20:05:56)*MartinReddy与所有人说:talking to each other because they realized they could help each other
(20:05:58)*MartinReddy与所有人说:END
(20:06:23)*MartinReddy与所有人说:Actually, I'll say a little more... :-)
(20:06:35)*MartinReddy与所有人说:Your question was really more about taking the time to write good APIs
(20:06:44)*MartinReddy与所有人说:I don't think I answered that very well
(20:06:59)*MartinReddy与所有人说:But it's a similar issue, that companies don't see the value of good API design
(20:07:23)*MartinReddy与所有人说:until there code has devolved and become unusable, at which point it's too late
(20:07:45)*MartinReddy与所有人说:It really takes someone with experience to be able to convince management that you actually
(20:08:02)*MartinReddy与所有人说:save time in the long term by spending more time writing good APIs up front
(20:08:20)*MartinReddy与所有人说:because the maintenance costs should be reduced over time
(20:08:39)*MartinReddy与所有人说:Hopefully that's a better answer to your question Liu Minye
(20:08:40)*MartinReddy与所有人说:END
|