问:
Difference between various Collection Generic Interfaces in C#
I have been playing around with C# for Windows and ASP.net MVC development for some time now. But I am still unclear on a few areas.  I am trying to understand the basic difference between and performance issues with using and interchanging similar kinds of Generic Collection Interfaces.

What is the basic difference between IEnumerable<T>, ICollection<T>, List<T>(Class)?

I seem to use and interchange them without seeing any problem in my applications. Also, are there any more similar generic collections like these that can be interchanged with those three?

答:
List<T> is a class and implements both the ICollection<T> and IEnumerable<T> interfaces. Also, ICollection<T> extends the IEnumerable<T> interface. They are not interchangeable, at least not from all points of view.

If you have a List<T>, you are guaranteed that this object implements methods and properties required to be implemented by the ICollection<T> and IEnumerable<T> interface. The compiler knows it and you are allowed to cast them "down" to either an ICollection<T> or an IEnumerable<T> implicitly. However, if you have an ICollection<T> you have to check explicitly in your code first whether it is a List<T> or something else, perhaps a Dictionary<T>  (where T is a KeyValuePair) before casting it to what you desire.

You know that ICollection extends IEnumerable, so you can cast it down to an IEnumerable. But if you only have an IEnumerable, again you are not guaranteed that it is a List. It may be, but it could be something else. You should expect an invalid cast exception if you do attempt to cast a List<T> to a Dictionary<T> for example.

So they are not "interchangeable".

Also, there are a lot of generic interfaces, check out what you can find in the System.Collections.Generic namespace.

Edit: regarding your comment, there is absolutely no performance penalty if you use List<T> or one of the interfaces it implements. You will still need to create a new object, check out the following code:

```<code>List<T> list = new List<T>();
ICollection<T> myColl = list;
IEnumerable<T> myEnum = list;
</code>```

list, myColl, and myEnum all point to the same object. Whether you declare it as a List or an ICollection or an IEnumerable I'm still requiring the program to create a List. I could have wrote this:

```<code>ICollection<T> myColl = new List<T>();
</code>```

myColl, at runtime is still a List.

However, an this is the most important point... to reduce coupling and increase maintainability you should always declare your variables and method parameters using the lowest possible denominator possible for you, whether it is an interface or an abstract or concrete class.

Imagine that the only thing the "PerformOperation" method needs is to enumerate elements, do some work and exit, in that case you do not need the hundred more methods available in List<T>, you only need what is available in IEnumerable<T>, so the following should apply:

```<code>public void PerformOperation(IEnumerable<T> myEnumeration) { ... }
</code>```

By doing that, you and other developers know that any object of a class implementing the IEnumerable<T> interface may be given to this method. It may be a List, a Dictionary, or a custom collection class another developer has wrote.

If on the contrary you specify you explicitly need a concrete List<T> (and although it is rarely the case in real life, it may still happen), you and other developers know that it must either be a List or another concrete class inheriting from List.

Body:
List<T> is a class and implements both the ICollection<T> and IEnumerable<T> interfaces. Also, ICollection<T> extends the IEnumerable<T> interface. They are not interchangeable, at least not from all points of view.

If you have a List<T>, you are guaranteed that this object implements methods and properties required to be implemented by the ICollection<T> and IEnumerable<T> interface. The compiler knows it and you are allowed to cast them "down" to either an ICollection<T> or an IEnumerable<T> implicitly. However, if you have an ICollection<T> you have to check explicitly in your code first whether it is a List<T> or something else, perhaps a Dictionary<T>  (where T is a KeyValuePair) before casting it to what you desire.

You know that ICollection extends IEnumerable, so you can cast it down to an IEnumerable. But if you only have an IEnumerable, again you are not guaranteed that it is a List. It may be, but it could be something else. You should expect an invalid cast exception if you do attempt to cast a List<T> to a Dictionary<T> for example.

So they are not "interchangeable".

Also, there are a lot of generic interfaces, check out what you can find in the System.Collections.Generic namespace.

Edit: regarding your comment, there is absolutely no performance penalty if you use List<T> or one of the interfaces it implements. You will still need to create a new object, check out the following code:

List<T> list = new List<T>();
ICollection<T> myColl = list;
IEnumerable<T> myEnum = list;

list, myColl, and myEnum all point to the same object. Whether you declare it as a List or an ICollection or an IEnumerable I'm still requiring the program to create a List. I could have wrote this:

ICollection<T> myColl = new List<T>();

myColl, at runtime is still a List.

However, an this is the most important point... to reduce coupling and increase maintainability you should always declare your variables and method parameters using the lowest possible denominator possible for you, whether it is an interface or an abstract or concrete class.

Imagine that the only thing the "PerformOperation" method needs is to enumerate elements, do some work and exit, in that case you do not need the hundred more methods available in List<T>, you only need what is available in IEnumerable<T>, so the following should apply:

public void PerformOperation(IEnumerable<T> myEnumeration) { ... }

By doing that, you and other developers know that any object of a class implementing the IEnumerable<T> interface may be given to this method. It may be a List, a Dictionary, or a custom collection class another developer has wrote.

If on the contrary you specify you explicitly need a concrete List<T> (and although it is rarely the case in real life, it may still happen), you and other developers know that it must either be a List or another concrete class inheriting from List.


问:
Is "PHP and MySQL Web Development, 4th ed." an outdated book to learn from?
I want to get into web stuff, and thought of going with PHP+MySQL. I have experience in C#, C++, desktop graphics, but no web stuff besides HTML, CSS which I started learning 2 months ago.

On SO PHP-book question, the highest rated book is "PHP Objects, Patterns and Practice". However, I'm not sure if it's a book to start PHP with... or is it? Most of the books mentioned in that SO question seem to be for those who already know PHP.

I considered "PHP & MySQL Web Development, 4th Ed.", but someone mentioned that "it uses the mysql_* functions which are almost deprecated."

Help?

答:
PHP Objects, Patterns and Practice is an excellent book, but you are correct in assuming is not for begginers. It's main objective is to help you understand design patterns in PHP.

PHP & MySQL Web Development, 4th Ed. is a little bit outdated, it's not just the use of mysql_* functions, but that alone is enough.

Two beginner oriented books that focus on PHP 5.3 are:

Beginning PHP and MySQL: From Novice to Professional

Beginning PHP 5.3 (Wrox Programmer to Programmer)

As for online resources:

The PHP manual is the authoritative source on all things PHP. Just ignore user comments, they are usually crap. There are some true gems in the comments, but as a beginner it won't be easy to identify them, so just ignore them.

PHP - The right way is a well written introduction to the language.

phpmaster.com articles are (usually) extremely well written and very thorough. If they feel a bit too much, don't worry they have a beginners section.

ContentLicense: CC BY-SA 3.0


问:
Good techniques to speed up database execution
I have an ASP.Net application that is using a MySQL database. My queries are not executing as fast as I would like them too. Are there some standard ways to increase the speed of a MySQL database short of putting it on a faster PC.

For example, (I'm not sure if these are true or not) using prepared statements over transactional SQL. Using foreign keys if applicable? Things along those lines.

EDIT:
The database is on a remote machine

答:
Speeding a database is a big subject, also, you need to tell us whether you have problems in querying the database, updating or deleting data. However, there are known facts that you can check:

0 - Make sure you are using the appropriate driver to connect to the database and that you are using the correct way to connect (for example using ODBC may be slower than a native driver). Use connection pools.

1 - Have a correct design.

2 - Have PK and FK defined with the same data type to speed joins.

3 - Create indexes on PK and FK for non-trivially sized tables

4 - Choose the right type of indexes

5 - Optimize your selects. Avoid "SELECT *" and don't join to tables unless you need to

6 - Qualify your selects properly so that the number of data rows returned is just enough to do the business function at hand. Don't return all the data all the time unless you need to.

7 - Avoid using large binary objects in queries. Consider removing photos from database to file system storage if possible.

8 - Use aggregate functions and ORDER BY wisely. Choose your clustering index so that you could avoid sorts if possible.

8a - Avoid using Not in WHERE and attempt to avoid complex transform operations.

8b - Make sure indexes are used in your queries otherwise tune the queries to utilize indexes or create the necessary indexes.

9 - Use a single column to build the key rather than multiple columns when possible.

10 - Check your physical design of tables and indexes. See how your space is allocated

11 - Consider index rebuilding and file system defragmanation

12 - Check strategies for fine tuning full-text-search (if you are using it) - See: FTS

13 - Determine if your network speed is good enough.

14 - Compare the transaction time in your ASP.NET application vs. the same query or transaction when performed on a console. The difference should be close. If you find a big variation then the problem may be with how you connect, the network or some other problem.


答:
Have a look at the MSDN pages for ICollection and IEnumerable.

In very abstract terms, this is how I conceive of these types.

An IEnumerable is anything that can be enumerated - that is, iterated over. It doesn't necessarily mean a 'collection'; for example, an IQueryable implements IEnumerable and it's not a collection, but is something that can be queried to return objects. To implement IEnumerable an object only needs to be able to return an object when queried. I might say that I have an Enumerable of tasks that I'm going to do today (it's not a list because I haven't written it down or formulated it, but I could tell you what I'm going to do now, and if you asked 'and then?' I'd be able to tell you the following task).

An ICollection is more concrete than an IEnumerable. A key difference is that a Collection knows how many items it contains; to work out how many items are in an Enumerable you effectively loop through and count them:

Me: Guys, how many items do you each have in you?

Enumerable: I don't really know. Well, here's one item. I've got another one, so that's two. And another one, so that's three... and another one... ok so that's 2382. No more items, so I've got 2382. Don't ask me again because I'll have to go through them all again.

Collection: I've got 2382 items. I already know that.

A collection is typically something that already knows where all its elements are, and won't have to go and find or generate them when you ask for them. It's more... concrete than an Enumerable.

In my opinion the different between an Enumerable and a Collection is much larger than the difference between a Collection and a List. In fact I'm struggling to think of a practical difference between a Collection and a List, but I believe List provides better methods for searching and ordering.

Other types of Collection include Queue and Stack, as well as Dictionary.

The names of these types are quite useful - you can conceive of a queue and a stack as their real world counterparts, and consider the differences you might have to a List.

Title: Difference between various Collection Generic Interfaces in C#

Body:
I have been playing around with C# for Windows and ASP.net MVC development for some time now. But I am still unclear on a few areas.  I am trying to understand the basic difference between and performance issues with using and interchanging similar kinds of Generic Collection Interfaces.

What is the basic difference between IEnumerable<T>, ICollection<T>, List<T>(Class)?

I seem to use and interchange them without seeing any problem in my applications. Also, are there any more similar generic collections like these that can be interchanged with those three?


问:
How large is ok for a Class?
I’m a long time developer (I’m 49) but rather new to object oriented development. I’ve been reading about OO since Bertrand Meyer’s Eiffel, but have done really little OO programming.

The point is every book on OO design starts with an example of a boat, car or whatever common object we use very often, and they start adding attributes and methods, and explaining how they model the state of the object and what can be done with it.

So they usually go something like "the better the model the better it represents the object in the application and the better it all comes out".

So far so good, but, on the other hand, I’ve found several authors that give recipes such as “a class should fit in just a single page” (I would add “on what monitor size?" now that we try not to print code!).

Take for example a PurchaseOrder class, that has a finite state machine controlling its behavior and a collection of PurchaseOrderItem, one of the arguments here at work is that we should use a PurchaseOrder simple class, with some methods (little more than a data class), and have a PurchaseOrderFSM “expert class” that handles the finite state machine for the PurchaseOrder.

I would say that falls in the “Feature Envy” or “Inappropriate Intimacy” classification of Jeff Atwood's Code Smells post on Coding Horror. I’d just call it common sense. If I can issue, approve or cancel my real purchase order, then the PurchaseOrder class should have issuePO, approvePO and cancelPO methods.

Doesn’t that goes with the “maximize cohesion” and “minimize coupling” age old principles that I understand as cornerstones of OO?

Besides, doesn’t that helps toward the maintainability of the class?

答: In my opinion class size doesn't matter as long as the variables, functions and methods are relevant to the class in question.</p>

Title: How large is ok for a Class?


问:
Should a programmer fix someone else's failed build?
One programmer committed some work to the SVN repository, then went home. After he left, the Hudson automatic build failed. Another programmer saw this, and after looking through the code changes, detected that the problem was the absence of one library. He added this library to SVN and the next build completed successfully.

Did the second programmer do the right thing or should he have just waited until the first programmer fixed the issue?

答:
My motto, is don't commit to SVN after 3pm that way you can always fix your own build failures.

If you do not fix his/her build failure, then everybody else's build will also fail. I would fix it to save time in the long run, but make sure they are aware that you had to fix it.

Having some sort of 'point the finger of blame' script is a good way to do this, or make the person who breaks the build buy donuts!!


答:
It depends to some extent on how your team usually works, but I would say that was fine.  Keeping the build working saves everyone else time.

It's polite for the the second programmer to drop the first an email to explain what he has done, just in case a specific version of the library is needed or there is some other complication.  It's also a slightly more subtle way to point out that they had broken the build.

Title: Should a programmer fix someone else's failed build?

Body:
One programmer committed some work to the SVN repository, then went home. After he left, the Hudson automatic build failed. Another programmer saw this, and after looking through the code changes, detected that the problem was the absence of one library. He added this library to SVN and the next build completed successfully.

Did the second programmer do the right thing or should he have just waited until the first programmer fixed the issue?


答:
It depends.

Is the bug so obvious that adding a library is the way to fix it? Sometimes the fix is in finding a workaround not to need that library.

Is the project in a phase where all changes must be linked to an existing ticket? If so, did you file a ticket? Has that ticket been assigned to you?

Anyway, focus on fixing the bug, not on blaming the responsible.


答: Why not? If your product is more important than fixing blames, it is certainly all right. Although a build failing because of library change is pretty lame and you need to reprimand the developer for not testing it.</p>


答:
The biggest problem with large classes is when it comes to testing those classes, or their interaction with other classes. Large class size by itself isn't a problem, but like all smells, it indicates a potential problem. Generally speaking, when the class is large, that's an indication that the class is doing more than a single class should.

For your car analogy, if class car is too large, that's probably an indication that it needs to be split into class engine, class doors, and class windshields, etc.

Title: How large is ok for a Class?

Body:
I’m a long time developer (I’m 49) but rather new to object oriented development. I’ve been reading about OO since Bertrand Meyer’s Eiffel, but have done really little OO programming.

The point is every book on OO design starts with an example of a boat, car or whatever common object we use very often, and they start adding attributes and methods, and explaining how they model the state of the object and what can be done with it.

So they usually go something like "the better the model the better it represents the object in the application and the better it all comes out".

So far so good, but, on the other hand, I’ve found several authors that give recipes such as “a class should fit in just a single page” (I would add “on what monitor size?" now that we try not to print code!).

Take for example a PurchaseOrder class, that has a finite state machine controlling its behavior and a collection of PurchaseOrderItem, one of the arguments here at work is that we should use a PurchaseOrder simple class, with some methods (little more than a data class), and have a PurchaseOrderFSM “expert class” that handles the finite state machine for the PurchaseOrder.

I would say that falls in the “Feature Envy” or “Inappropriate Intimacy” classification of Jeff Atwood's Code Smells post on Coding Horror. I’d just call it common sense. If I can issue, approve or cancel my real purchase order, then the PurchaseOrder class should have issuePO, approvePO and cancelPO methods.

Doesn’t that goes with the “maximize cohesion” and “minimize coupling” age old principles that I understand as cornerstones of OO?

Besides, doesn’t that helps toward the maintainability of the class?

ContentLicense: CC BY-SA 2.5


问:
Does it make sense to standardize including a created date and last updated date field on all DB tables?
My boss is currently attempting to apply some development standards to our team, so we had a meeting yesterday to discuss the standards which was mostly going well until she brought up:

All DB tables will have a CreatedDate and LastUpdatedDate column, updated by triggers.

At this point our team suffered an opinion schism; one half of us think that doing this on all tables is a large amount of work with little benefit (we work on fixed-budget projects so any cost comes from our company's profits); the second half believe it will help with support of the projects.

I am firmly in the former camp. While I appreciate that some outside cases would cause the extra columns to improve supportability, in my opinion the amount of work that would be required to add the columns in the first place, as well as maintenance, would cause us to spend less time on more important things like Unit- or Load-Testing. Also, I'm fairly sure that these extra columns would make it more awkward to use an ORM - bearing in mind that we mainly use C# and Oracle, which isn't very ORM-happy to start with.

So, my question is twofold:

Am I in the right camp? I don't claim to have world-renowned database skills, so this might be a trivially easy addition with no adverse side-affects.

How would you deal with a situation where a meeting about standards devolves into a slagging match? How can I really sell that this standard is not going to help us in the long term?

答:
This is a fairly common practice, although I wouldn't say supportability is the main benefit. The real benefit for this approach is keeping an audit trail. It's also common place to have an extra column containing the username of the user who made the last update.

If you're dealing with any kind of financial or sensetive data, I'm sure you've heard of things like PCI & SOX compliance. Having a comprehensive audit trail is essential in meeting those specifications..

Disclaimer: There are however, much better ways of achieveing a database audit trail > https://stackoverflow.com/questions/1051449/ideas-on-database-design-for-capturing-audit-trails

ContentLicense: CC BY-SA 4.0


答:
Someone needs to fix it and the first programmer should not have gone home without first making sure that he had not broken the build. However, for such an easily fixed problem, calling him back to fix it himself would be extreme.

I agree with Luke Graham's suggestion of sending an explanatory e-mail, although I'd say it's more than polite - it's basic communication.


问:
VB.Net vs C# debate
I've been in workplaces where, at the start of a project, the "Should we use VB.Net or C#" question has been raised.

Granted, it's probably less common to have to make that decision now than it was in the early days of .Net, particularly given the trend towards language convergence, but it can still be a heated debate.

So, between VB.Net and C#, Which language do you prefer and why?

答:
I prefer the bracket syntax of C-style languages to the more "verbose" syntax of BASIC-style languages.

My introduction to programming was with Turbo Pascal.  (The bit of BASIC programming I did on the Commodore 64, as a child, doesn't really count.)  After learning Java I never looked back and have preferred C-style syntax.

Title: VB.Net vs C# debate


问:
What's your favourite quote about programming?
What's your favourite quote about programming?

One quote per answer, and please check for duplicates before posting!

答:
"The complexity you remove can never
  fail"
  -- Burt Rutan on the  Ansari X Prize

LastEditorDisplayName: Roger Pate

OwnerDisplayName: emericle


答:
Build failures happen. If it's important that a daily build happen then I would fix it and then request that the developer that checked in the broken code to review the fix the next day and ensure that the code is now as it should be. </p>

<p>As has been said, the guy who fixed it should probably email the guy who broke it and detail what the fix was. </p>

Body:
Build failures happen. If it's important that a daily build happen then I would fix it and then request that the developer that checked in the broken code to review the fix the next day and ensure that the code is now as it should be.

As has been said, the guy who fixed it should probably email the guy who broke it and detail what the fix was.


问:
Tabs versus spaces—what is the proper indentation character for everything, in every situation, ever?
The coding standards for the code hosted in drupal.org suggest to use two spaces to indent the code; other sites suggest to use tabs to indent the code.

What is the proper indentation character for everything, and in every situation? Please explain the answer you give.

答:
Plenty of arguments have been given already, but nobody mentioned where we could be headed in the future.

Tabs nor spaces!

Ideally code should be considered data, and not be stored in any specific text formatting. Any developer can apply his own preferred view. Furthermore, this view shouldn't be limited to just text, but can include tables, color pickers and mathematical formulas.

This idea isn't too far-fetched. It was JetBrain's Language Oriented Programming editor Meta Programming System (MPS) which first made me realize this resolves the entire discussion, simultaneously adding a lot of extra possibilities. (Yes this is possible with editor plugins, but working on text directly adds so many unnecessary complexities, as opposed to the approach MPS takes.)

As opposed to tabs and spaces, there are little disadvantages which can be mentioned for working directly on abstract syntax trees. All that is needed is for the technology to mature to a commercially viable product. The first signs of this are showing up. Largely built upon MPS, a commercial actionscript editor, Realaxy was created.

I'd love to see one of the big players jump on the concept of this technology and see what happens!


问:
Why these attempts to water down Scala with Xtend and Kotlin?
So now Eclipse has offered Xtend and JetBrains is offering Kotlin - both of which seem to be watered down versions of Scala. My question is why?  I've played with Scala a bit and it's not that hard.  Is this just a reaction to the inherent difficulty of the leap from imperative to functional or is there something else at work here?

EDIT: Apologies.  Rereading the question as I originally posted it I can see where it sounds a bit like trolling.  The way I phrased the question just seemed to be the best way to ask the question.  I have seen blog postings to the effect "Scala is too hard/Scala is too complex" and also "Kotlin is an attempt to do Scala but simpler".  I'll leave the phrasing as it was originally but I honestly wasn't trying to troll.

答:
JetBrains has very clearly stated their objectives for Kotlin:

We want to become more productive by switching to a more expressive language. At the same time, we cannot accept compromises in terms of either Java
  interoperability (the new language is going to be introduced
  gradually, and needs to interoperate smoothly with the existing code
  base) or compilation speed (our code base takes long enough to compile
  with javac, and we cannot afford making it any slower). The next thing is also fairly straightforward: we expect Kotlin to drive the sales of IntelliJ IDEA.


答:
JetBrains has a wiki page comparing Scala to Kotlin, and there seem to be a few things that Kotlin does and Scala does not:

Zero-overhead null-safety. Scala has Option, which is a syntactic and run-time wrapper

Smart casts

Static extension functions. Instead of wrapping at runtime

Kotlin's Inline functions facilitate Nonlocal jumps

String templates. There's 3rd party compiler plugin for scala with similar functionality: ScalaEnhancedStrings

First-class delegation. Also implemented via 3rd party plugin: Autoproxy
  Modules

So calling Kotlin a water down Scala is probably an oversimplification. As for Xtend, I think it targets mostly Xtext users, rather than a wider audience. A major difference to Scala is that Xtend compiles to Java rather than bytecode.

Another "Java killer" language you should add to your list is Red Hat's Ceylon, although I have no idea if and how it compares to Scala.

Title: Why these attempts to water down Scala with Xtend and Kotlin?

Body:
So now Eclipse has offered Xtend and JetBrains is offering Kotlin - both of which seem to be watered down versions of Scala. My question is why?  I've played with Scala a bit and it's not that hard.  Is this just a reaction to the inherent difficulty of the leap from imperative to functional or is there something else at work here?

EDIT: Apologies.  Rereading the question as I originally posted it I can see where it sounds a bit like trolling.  The way I phrased the question just seemed to be the best way to ask the question.  I have seen blog postings to the effect "Scala is too hard/Scala is too complex" and also "Kotlin is an attempt to do Scala but simpler".  I'll leave the phrasing as it was originally but I honestly wasn't trying to troll.


答:
IMHO from somebody programming in Java for the last 7 years and being my strongest language, I find Scala quite alien and am having a hard time getting used to it.

Xtend feels more like Java and was able to write a simple application with it much quicker.  Granted I didn't give myself enough time with Scala, but I certainly understand why some may be turned off by it.

With that being said, people will choose a familiar hell over an unfamiliar heaven.


问:
One stop shop for good coding practices and performance tips?
While this may be a very subjective question I was wondering if there's a place (or many places) on the web where one can read up about good coding and performance tips for different languages and how they may compare with others?

For example in AS3 it's faster to multiply rather than to divide, is this the same for JS? What other tips are there to really make our code run lightening fast? And where are these tips?

答:
I think this website i.e Programmers.StackExchange is basically aimed at this types of problems and question only. Here is an excerpt from the FAQ page :-

Programmers — Stack Exchange is a site for professional programmers who are interested in getting expert answers on conceptual questions about software development. If you have a question about…

algorithm and data structure concepts

design patterns

developer testing

development methodologies

freelancing and business concerns

quality assurance

software architecture

software engineering

software licensing


答:
I have used Scala a few months in Eclipse with Play Framework. I like the language but there is also things that I don't like.

For me, the reason to switch from Java to another language is to be more productive.

So far I haven't been more productive with Scala. One reason is the lack of good support for Scala in Eclipse, the Scala plugin is bad (e.g. indentation fails) and doesn't have many functions yet (e.g. no "Open Call Hierarchy"). The Scala compiler is also slow, this may not be a problem, but I use Scala with Play Framework, that compiles the code for every request, and there the compiler speed is important.


问:
Stuff every programmer needs while working
I've been tasked with creating a fun and relaxing environment, one thing I know that I want is ergonomic mice and keyboards, others have suggested exercise balls and bands.

What is it that every programmer needs while working? What might not be necessary but would be nice to have anyway?

Note: this question was asked previously, but has been recommended to be posted here. See this link for the previous responses: https://stackoverflow.com/questions/3911911/stuff-every-programmer-needs-while-working-closed

答:
A manager who takes care of the knuckle-head stuff: endless meetings, repetitive and easily answered tech-support questions, requests to "fix my computer", etc.

When I was a manager, I made it clear that no one was to disturb my programmers or schedule them in a meeting without coming to me first.


答:
The former argument is invalid, because adding a few database maintained timestamp fields to a series of tables is not difficult work.  This is in fact the kind of mind numbing task that one would give to a junior or an intern, and they could easily do it in a single two week sprint with time to spare.

It may or may not even be necessary to map these fields in your ORM, simply because you do not want application users to modify these fields and because they are useful for maintenance and debugging and rarely have use in business logic.  I worked in shops that did it both ways and I frankly don't have much of an opinion on this either way.

The benefits, even if exagerated still far outweigh any human costs in implementing such functionality at the database level, and certainly probably less than the collective brain power of the projects great technical minds hijacking the meeting and sparring it out in an epic chest thumping match.  When you tally up the impact that a few 1 hour meetings have on the lifespan of a project you probably won't be surprised that they are expensive.  Imagine the collective hourly wages and benefits of all of those people combined and that should give you an idea.

Title: Does it make sense to standardize including a created date and last updated date field on all DB tables?

Body:
My boss is currently attempting to apply some development standards to our team, so we had a meeting yesterday to discuss the standards which was mostly going well until she brought up:

All DB tables will have a CreatedDate and LastUpdatedDate column, updated by triggers.

At this point our team suffered an opinion schism; one half of us think that doing this on all tables is a large amount of work with little benefit (we work on fixed-budget projects so any cost comes from our company's profits); the second half believe it will help with support of the projects.

I am firmly in the former camp. While I appreciate that some outside cases would cause the extra columns to improve supportability, in my opinion the amount of work that would be required to add the columns in the first place, as well as maintenance, would cause us to spend less time on more important things like Unit- or Load-Testing. Also, I'm fairly sure that these extra columns would make it more awkward to use an ORM - bearing in mind that we mainly use C# and Oracle, which isn't very ORM-happy to start with.

So, my question is twofold:

Am I in the right camp? I don't claim to have world-renowned database skills, so this might be a trivially easy addition with no adverse side-affects.

How would you deal with a situation where a meeting about standards devolves into a slagging match? How can I really sell that this standard is not going to help us in the long term?


答:
The workload is moot because this can be scripted and applied to every database you'll ever create. Add the columns to all tables along with the triggers. You just have to remember to run it with your build.

As far as what the client wants, you can have them pay you to integrate them in your app as they see fit. Many like to see additional information on a record like who created/changed it last and when. No need to send everyone an email to find out or be lied to. You don't want to have to query a log every time someone looks at a record.

Putting it in the database and having it there just in case isn't that difficult and may allow you to charge for additional features that utilize the fields or just to give you some feedback on how much clients are using the system.


答:
Yes it's okay. However, it's unprofessional for the original programmer to go home before testing wether the build would compile.

Your reputation is 100% in your control. Stuff like this tarnishes your reputation and trying to polish a tarnished reputation is very difficult.


答:
Communicate

There is no strict rules (beside your own team rules) for those scenario.

Dev2 should be able to tell dev1 he can fix his error, neither one of them should fear something resulting from this exchange, they are part of a team.


答:
The real question you should ask yourself first is: "Should I already be thinking about performance?"

Usually you should only be concerned about performance once you run into performance issues.  Here is one of my favorite quotes:

It is easier to optimize correct code than to correct optimized code. - Bill Harlan

For performance problems caused by inefficient algorithms (or hobbyist discussions irrelevant to an actual project) you are best off here at Programmers. For language specific performance problems you are better off at Stack Overflow.

And to answer your actual question:
If a site which lists performance statistics for every language (comparing features) existed, how would you use it? Would you choose one language over the other because it does faster virtual calls?

Title: One stop shop for good coding practices and performance tips?

Body:
While this may be a very subjective question I was wondering if there's a place (or many places) on the web where one can read up about good coding and performance tips for different languages and how they may compare with others?

For example in AS3 it's faster to multiply rather than to divide, is this the same for JS? What other tips are there to really make our code run lightening fast? And where are these tips?


答:
Things happen. The failure to add a new code file (whether source or compiled) to Subversion is probably the most common cause of broken builds, assuming it worked on the developer's computer. At my last job with a CI environment, even the most senior guys sometimes forgot.

I think, if another person was able to fix the build and thus keep the team humming along, that's fine. I do think the programmer who went home needs at least a friendly e-mail stating what happened, and to remind him to make sure that new code gets added before commits. If it happens often, maybe make that a minor offense punishable by the "dance of shame", to help reduce occurrences (and lighten the mood).


答: It's OK to fix unless this is a regular occurance in which case I would have the boss call him and make him return and fix it himself.</p>


问:
What should you include in a development approach document?
I'm in the middle of co-producing a "development approach" document for off-shore resources as they ramp up onto our project.

The most recent (similar) document our company has used is over 80 pages, and that does not include coding standards/conventions documents.

My concern is that this document will not be consumable and will therefore fail.

What should be in a development approach document?
Are there any decent guidelines on this topic?

EDIT: The development approach document should detail the practices and techniques that will be used by software developers while software is designed, built, and tested.

答:
Development practices change over time as your requirements change and as the set of languages, libraries and frameworks you use change. This change is inevitable and will mean that anything you put on paper is going to be outdated (almost) immediately. The way to deal with this? Keep it all in a wiki, and encourage everyone on your team — both internal and external — to help keep it updated and relevant.

Once you've taken the step from a dead document to a living one, the debate of what to put in becomes less urgent: you just put in what you can think of now and come back to it at a later date. (The good thing is that you won't have to understand everything in order to write the document in the first place.) You might also want to seed it all with the outdated content from the old 80-page doc; that'll give you a lot of outline material if nothing else, saving you from having to think about writing huge scads of boring stuff.


答:
We have the created date and created by columns in our database and they have helped us tremendously in tracking down data issues. If we need to revert, it helps us to find the correct records in the full audit tables (because we know where to look in a very large table). She should add a created by and modified by columns too. It really really helps to know who put the data in especially if you don't have full auditing.

I can think of no Enterprise application which doesn't need auditing of some form or another. Apparently your boss thinks it needs only relatively mild auditing. Personally I favor full auditing on every database that contains data your company is dependant on (it's a whole lot easier to revert those 2000 bad records from audit tables than to restore backups) and would require it if there is any financial information at all as I have seen this type of thing help catch people committing fraud. All auditing must be at the database level.

How can this data help? Well first it narrows down when to look to find the old data (in a revision) and it can help you see what version of your program was active at the time the data was entered. So if you know you fixed that problem in version 2.3 which went live on 6 July 2011 and then found the same problem with a record inserted on Aug 7, then maybe your fix wasn't good. If you need to revert to old data it will tell you what version of the backups you can find the old data in if you don't have full auditing.

Developers rarely seem to think that data must be maintained over time and that bad data needs to get fixed by someone. Having things like that can be very valuable to those of us who have to do such things. Your boss is right, although I don't think she went far enough in auditing. It only takes one really serious problem that is easy to fix to justify the very small amount of time it will take to add these columns and triggers.


问:
Is anyone here Zend certified? Do they recommend it?
For the amount of web developer job interviews I've been to, I'm somewhat surprised that no one has brought up Zend certification. Has anyone ever been certified before, or is it a waste of time/money?</p>

答:
As a full time PHP Developer, I have never had anybody ask if I was Zend certified.

I have not taken the certification exam, and I don't foresee myself taking it in the future. While it may give you one up on your competition in an interview, I think the same thing can be achieved by simply knowing your craft.

By all means, take the exam if you like, but I don't think it will help you in your PHP career.

--Edit--

Also, when I DID look at the Zend certification (back in the early PHP5 days), I noticed there was a lot of weight put on memorization of function names and parameters. I don't feel this makes you a better programmer, which had a huge weight in my decision not to take the exam.


答: I tend to shy away from technology-specific certifications for the reason that Craige mentioned in his answer - they focus on things like functions, parameters, and language features that change (sometimes rapidly) over time. I would rather see projects and work history using technology, rather than certifications. These would demonstrate your grasp of language functions and show me how you design and implement systems. The certifications that I would look for are those by well-respected organizations that offer technology-independent validation of knowledge about a given set of concepts.</p>

Title: Is anyone here Zend certified? Do they recommend it?

Body: For the amount of web developer job interviews I've been to, I'm somewhat surprised that no one has brought up Zend certification. Has anyone ever been certified before, or is it a waste of time/money?</p>


答: Maybe a company that is a programming consultancy likes to claim their devs are Zend certified. They would probably just hire good programmers and require taking the exam which they would pay for. This is big in the Microsoft world (To be Gold Certified?). Not sure how much it applies here.</p>


问:
How to choose between Tell don't Ask and Command Query Separation?
The principle Tell Don't Ask says:

you should endeavor to tell objects what you want them to do; do not
  ask them questions about their state, make a decision, and then tell
  them what to do.

The problem is that, as the caller, you should not be making decisions
  based on the state of the called object that result in you then
  changing the state of the object. The logic you are implementing is
  probably the called object’s responsibility, not yours. For you to
  make decisions outside the object violates its encapsulation.

A simple example of "Tell, don't Ask" is

```<code>Widget w = ...;
if (w.getParent() != null) {
  Panel parent = w.getParent();
  parent.remove(w);
}
</code>```

and the tell version is ...

```<code>Widget w = ...;
w.removeFromParent();
</code>```

But what if I need to know the result from the removeFromParent method? My first reaction was just to change the removeFromParent to return a boolean denoting if the parent was removed or not.

But then I came across Command Query Separation Pattern which says NOT to do this.

It states that every method should either be a command that performs
  an action, or a query that returns data to the caller, but not both.
  In other words, asking a question should not change the answer.
  More formally, methods should return a value only if they are
  referentially transparent and hence possess no side effects.

Are these two really at odds with each other and how do I choose between the two? Do I go with the Pragmatic Programmer or Bertrand Meyer on this?

答:
If you need to know the result, then you do; that's your requirement.

The phrase "methods should return a value only if they are referentially transparent and hence possess no side effects" is a good guideline to follow (especially if you're writing your program in a functional style, for concurrency or other reasons), but it's not an absolute.

For example, you may need to know the result of a file write operation (true or false).  That's an example of a method that returns a value, but always produces side effects; there's no way around that.

To fulfill Command/Query Separation, you would have to perform the file operation with one method, and then check its result with another method, an undesirable technique because it decouples the result from the method that caused the result.  What if something happens to the state of your object between the file call and the status check?

The bottom line is this: if you are using the result of a method call to make decisions elsewhere in the program, then you are not violating Tell Don't Ask.  If, on the other hand, you're making decisions for an object based on a method call to that object, then you should move those decisions into the object itself to preserve encapsulation.

This is not at all contradictory with Command Query Separation; in fact, it further enforces it, because there's no longer a need to expose an external method for status purposes.


问:
Why scalability issues cannot be solved by more servers ?
I know that big websites suffer from scalability issues and I guess that more servers (hardware) can help to handle scalabililty issues but I see that big websites are stuck about scalability even if they can handle the cost of new servers.

So why can big companies not handle scalability issues by more servers?

答:
By introducing more servers, you are introducing more lines of communication and the need to keep things synchronized. This is not trivial.

The amount of communications overhead goes up quadratically with the number of nodes communicating. If you try to centralize communications you then introduce a scalability bottleneck with communications.

There are several known architectures used for scaling and none of them are simple as "add more servers".

The High Scalability Blog have featured a recent blog post just this subject.


问:
Mixing jQuery with JavaScript
I just asked this question at SO about some bugginess I am experiencing with jQuery and IE8, and someone commented that he was appalled that I would mix JavaScript with jQuery (he has since deleted his comment for some reason).

This person had a high reputation, relative to mine (3000+), so I don't want to ignore his criticism. I'm still relatively new to web development, and I mostly work alone, so I wasn't aware that this could be a problem. Why should mixing the two be avoided?

答:
Not sure where such criticism would come from, seeing as jQuery is javascript.

The comment seems to have been deleted, so it is difficult to say exactly what the criticism was about. Could be more about your usage of jQuery or javascript.

Title: Mixing jQuery with JavaScript


问:
How to share code as open source?
I have a little program that I wrote for a local group to handle a somewhat complicated scheduling issue for scheduling multiple meetings in multiple locations that change weekly according to certain criteria.  It's a niche need, but I wouldn't be surprised if there are other groups that could use software like this.  In fact, we've had requests from others for directions on starting a group like this, and if their groups get as big, they might also want special software to help with scheduling.  I plan to continue developing the program and eventually make it an online web app, but a very simple alpha version is completed as a console app.

I'd like to make it available as open source, but I have no idea what kind of process I should go through first.  Right now, all I have is Java code, not even unit-tested thoroughly.  I haven't shown the code to anyone else.  There is no documentation.  I don't know where I would put the code so others could access it.  I don't know anything about licensing it.  I don't know what kind of support people will expect from me if I release it as open source.  I have no idea what else I should worry about.

Can someone outline for me (or post an article(s) that outlines) the process of taking open source software from "coded" to "completed / available"?  I really don't want to embarrass myself by doing things weirdly.

答: Stick it on a public hosting site such a Codeplex, Github, Bitbucket, Google Code and put your preferred licence in the source code (or seperate text file) - job done!</p>

Title: How to share code as open source?


答:
The issue, and likely, the reason for the comment, seems to be the lines with document.getElementById('firstName');.  jQuery can do the exact same thing, and it's generally "safer", since it handles differences between browsers nicely.

The best rule of thumb to follow is use jQuery a DOM manipulation library of your choice (for many people, this is jQuery) to manipulate the DOM, and javascript for everything else you need to do.

Title: Mixing jQuery with JavaScript

Body:
I just asked this question at SO about some bugginess I am experiencing with jQuery and IE8, and someone commented that he was appalled that I would mix JavaScript with jQuery (he has since deleted his comment for some reason).

This person had a high reputation, relative to mine (3000+), so I don't want to ignore his criticism. I'm still relatively new to web development, and I mostly work alone, so I wasn't aware that this could be a problem. Why should mixing the two be avoided?


答:
Some programmers tends to think in terms of what a tutorial or some programmer guru states.

Most probably, it would be easier to have the same framework used in your application to make the code easier to read and to understand.

But most of the times, frameworks have limitations or bugs so you can never apply what the tutorial or some programmer guru states.

I guess the most important is to satisfy the customer and to ship a bug free application

Title: Mixing jQuery with JavaScript


答:
People like being black and white.

If you're going to use a cross browser normalization tool then use it. Don't use it to normalize some things but not others.

Example

```<code>var a = $("#foo");
var b = document.getElementById("bar");
</code>```

Those two should not be mixed. Either you use jQuery for edge case bugs you might care about or you use the DOM for speed, but not both.

And yes personally I would also say:

WTF, write your code more coherently, why are you mixing DOM calls with jQuery calls.

As a side-note, you can assume that when he says "javascript and jQuery" he means "calls to the DOM API directly in javascript and calls to the DOM API through the jQuery abstraction layer". Any other comment would be misinformation / trolls.

Title: Mixing jQuery with JavaScript

Body:
People like being black and white.

If you're going to use a cross browser normalization tool then use it. Don't use it to normalize some things but not others.

Example

var a = $("#foo");
var b = document.getElementById("bar");

Those two should not be mixed. Either you use jQuery for edge case bugs you might care about or you use the DOM for speed, but not both.

And yes personally I would also say:

WTF, write your code more coherently, why are you mixing DOM calls with jQuery calls.

As a side-note, you can assume that when he says "javascript and jQuery" he means "calls to the DOM API directly in javascript and calls to the DOM API through the jQuery abstraction layer". Any other comment would be misinformation / trolls.


问:
Does a time estimate equal a promise in Scrum?
If an estimate is not a promise then as a product owner how can I deliver my projects without knowing how long it will take?

Does a Scrum team work more efficiently if we treat time estimates as a promise?

How much research (preparation, effort to understand the problem) in a story is enough to come up the right estimate?

What about unexpected technical problems (problems that can really mess your initial estimates) that come up after you estimate your work?

答:
If an estimate is not a promise then as a product owner how can I deliver my projects without knowing how long it will take?

This is one of the biggest misunderstandings about Scrum.  The question of "How long will my project take?" assumes that you can define, at some point in time, exactly what the project will entail in order to complete.  But the whole idea about Scrum is that it acknowledges that the things that you learn about a project, as you work on the project, are going to change the definition of the project.

The most common way to define a project is to list the features it will have.  Typically, a project is completed when all of the features have been implemented.  But what if, as you work on a project, you realize that 5 of the features identified at inception aren't going to be needed, but there's 7 features that people thought of in the first 6 months that really should be included?  What does that do to the question of how long it will take?

Another factor is that the things you learn will change your understanding of how to implement certain features, and as you get closer to implementing each feature your estimates are going to change.  Personally, I'd resist putting numeric estimates on anything not approaching the horizon of being implemented - maybe using descriptive estimates like "tiny", "small", "medium", "large" and "huge" or "epic".  Then you're not implying an accuracy greater than you're capable of estimating.

Truthfully, "How long will it take?", isn't answerable any more than, "What will it be when it's done?".  Accountants and traditional business people hate this, which is why it's very hard to move away from Waterfall in some organizations.

It's also why you need to take a lot of the talk about velocity and metrics with a grain of salt.  Software projects have a kind of Heisenberg's Uncertainty Principle built into them, and if you spend too much time fine tuning measurements you're just going to end up with extremely precise nonsense.

So no, an estimate isn't a promise.  It's an estimate.  The "promise" is the commitment the Team makes to complete a certain number of features or stories in a particular Sprint.

The estimates need be just accurate enough to allow the Team to identify how many features (or stories) they can fit into a Sprint snugly.  Even more important than accuracy in the estimates is consistency, because the Team will learn how much work worth of estimates they can fit into a Sprint, even if the actual work turns out to be usually twice as much as they estimated.  As long as it's consistently off, they'll be able to plan.

OwnerDisplayName: Preyash


答:
I don't think there is a specific definition of a class being too large. However, I would use the following guidelines to determine whether I should refactor my class or redefine the scope of the class:

Are there many variables that are independent of each other? (My personal tolerance is around 10~20 in most cases)

Are there many methods designed for corner cases? (My personal tolerance is ... well, it highly depends on my mood I guess)

In regards to 1, imagine that you define your windshield size, wheel size, tail light bulb model, and 100 other details in your class car . Although they are all "relevant" to the car, it is very difficult to trace the behavior of such class car. And when someday your colleague accidentally (or, in some case, intentionally) changes the windshield size based on the tail light bulb model, it takes you forever to find out why the windshield no longer fits into your car.

In regards to 2, imagine that you try to define all the behaviors a car may have in the class car, but car::open_roof() will be only available for convertibles, and car::open_rear_door() does not apply to those 2-door cars. Although convertibles and 2-door cars are "cars" by definition, implementing them in the class car complicates the class. The class becomes harder to use and harder to maintain.

Other than these 2 guidelines, I would suggest a clear definition of the class scope. Once you define the scope, implement the class strictly based on the definition. Most of the time, people get a "too large" class because of the poor definition of the scope, or because of the arbitrary features added to the class

Title: How large is ok for a Class?


答:
It depends, it depends...

As programmers, our work is to get things working, not to judge people. So I'd say that the best thing you can do is to fix it, or if it is not obvious, just roll back the changes and let the first programmer know so he can fix it later.

Anyway, having the latest guy that broke the build to wear a weird hat is enough to pay more attention the next time ^_^


答:
Adding more application servers works for a while, but the effect of adding more application servers is that you increase contention on the database server.

Database servers are much harder to scale by throwing more computers at the problem. The ACID properties that underpin how databases are used do not scale across many servers. Think about simultaneously applying the results of a transaction across 10 servers, and then what happens when there are 100,000 simultaneous transactions in progress.

That is where distributed databases step in. These products do not do ACID, they do CAP.  Effectively you have to choose two characteristics from consistency, availability and partition tolerance and allow the third one to slip.

The programming model is usually eventual consistency, so changes get distributed between the database servers over time. (usually in ms timescales), however this is not appropriate everywhere (e.g. Banking Sector with financial transactions).

Some systems claim to offer all three CAP properties, but I have yet to see one that truely achieves this

The distributed database does not do SQL, so the data access layer has tone rewritten. This kind of change takes time to implement, and requires new ways of thinking.

Title: Why scalability issues cannot be solved by more servers ?

Body:
I know that big websites suffer from scalability issues and I guess that more servers (hardware) can help to handle scalabililty issues but I see that big websites are stuck about scalability even if they can handle the cost of new servers.

So why can big companies not handle scalability issues by more servers?


答:
Actually your example problem already illustrates lack of decomposition.

Let's just change it a slight bit:

```<code>Book b = ...;
if (b.getShelf() != null)
    b.getShelf().remove(b);
</code>```

This is not really different, but makes the flaw more apparent: Why would the book know about its shelf? Simply put, it shouldn't. It introduces a dependency of books on shelves (which doesn't make sense) and creates circular references. It's all bad.

Likewise it is not necessary for a widget to know its parent. You will say: "Ok, but the widget needs it's parent to properly layout itself etc." and under the hood the widget knows its parent and asks it for its metrics to calculate its own metrics based on them etc. According to tell, don't ask this is wrong. The parent should tell all its children to render, passing all necessary information as arguments. This way one can easily have the same widget in two parents (whether or not this actually makes sense).

To come back to the book example - enter the librarian:

```<code>Librarian l = ...;
Book b = ...;
l.findShelf(b).remove(b);
</code>```

Please understand, that we're not asking anymore in the sense of tell, don't ask.

In the first version, the shelf was a property of the book and you asked for it. In the second version, we make no such assumption about the book. All we know is that the librarian can tell us a shelf that contains the book. Presumably he relies on some kind of lookup table to do so, but we don't know for sure (he could also just loop through all books in every shelf) and actually we don't want to know.

We do not rely on whether or how the librarians response is coupled to its state or that of other objects it might depend on. We tell the librarian to find the shelf.

In the first scenario, we directly encoded the relationship between a book and a shelf as a part of the book's state and retrieved this state directly. This is very fragile, because we also make the assumption that the shelf given back by the book contains the book (this is a constraint that we must ensure, otherwise we might be unable to remove the book from the shelf it's actually in).

With the introduction of the librarian, we model this relationship separately, therefore achieving separation of concern.

Title: How to choose between Tell don't Ask and Command Query Separation?

Body:
The principle Tell Don't Ask says:

you should endeavor to tell objects what you want them to do; do not
  ask them questions about their state, make a decision, and then tell
  them what to do.

The problem is that, as the caller, you should not be making decisions
  based on the state of the called object that result in you then
  changing the state of the object. The logic you are implementing is
  probably the called object’s responsibility, not yours. For you to
  make decisions outside the object violates its encapsulation.

A simple example of "Tell, don't Ask" is

```<code>Widget w = ...;
if (w.getParent() != null) {
  Panel parent = w.getParent();
  parent.remove(w);
}
</code>```

and the tell version is ...

```<code>Widget w = ...;
w.removeFromParent();
</code>```

But what if I need to know the result from the removeFromParent method? My first reaction was just to change the removeFromParent to return a boolean denoting if the parent was removed or not.

But then I came across Command Query Separation Pattern which says NOT to do this.

It states that every method should either be a command that performs
  an action, or a query that returns data to the caller, but not both.
  In other words, asking a question should not change the answer.
  More formally, methods should return a value only if they are
  referentially transparent and hence possess no side effects.

Are these two really at odds with each other and how do I choose between the two? Do I go with the Pragmatic Programmer or Bertrand Meyer on this?

Body:
Actually your example problem already illustrates lack of decomposition.

Let's just change it a slight bit:

Book b = ...;
if (b.getShelf() != null)
    b.getShelf().remove(b);

This is not really different, but makes the flaw more apparent: Why would the book know about its shelf? Simply put, it shouldn't. It introduces a dependency of books on shelves (which doesn't make sense) and creates circular references. It's all bad.

Likewise it is not necessary for a widget to know its parent. You will say: "Ok, but the widget needs it's parent to properly layout itself etc." and under the hood the widget knows its parent and asks it for its metrics to calculate its own metrics based on them etc. According to tell, don't ask this is wrong. The parent should tell all its children to render, passing all necessary information as arguments. This way one can easily have the same widget in two parents (whether or not this actually makes sense).

To come back to the book example - enter the librarian:

Librarian l = ...;
Book b = ...;
l.findShelf(b).remove(b);

Please understand, that we're not asking anymore in the sense of tell, don't ask.

In the first version, the shelf was a property of the book and you asked for it. In the second version, we make no such assumption about the book. All we know is that the librarian can tell us a shelf that contains the book. Presumably he relies on some kind of lookup table to do so, but we don't know for sure (he could also just loop through all books in every shelf) and actually we don't want to know.

We do not rely on whether or how the librarians response is coupled to its state or that of other objects it might depend on. We tell the librarian to find the shelf.

In the first scenario, we directly encoded the relationship between a book and a shelf as a part of the book's state and retrieved this state directly. This is very fragile, because we also make the assumption that the shelf given back by the book contains the book (this is a constraint that we must ensure, otherwise we might be unable to remove the book from the shelf it's actually in).

With the introduction of the librarian, we model this relationship separately, therefore achieving separation of concern.


答:
I think that you should go with your initial instinct. Sometimes the design should be intentionally dangerous, to introduce complexity immediately when you communicate with the object so that your forced handle it properly straight away, instead of trying to handle it on the object itself and hide all the gory details and make it hard to cleanly change the underlying assumptions.

You should get a sinking feeling if an object offers you implemented equivalents of open and close behaviors and you immediately begin to understand what your dealing with when you see a boolean return value for something you thought would be a simple atomic task.

How you deal with later on is your thing. You can create an abstraction above it, a widget type with removeFromParent(), but you should always have a low-level fallback, otherwise your were possibly making premature assumptions.

Don't try to make everything simple. There's nothing as disappointing when your rely on something that appears to be elegant and so innocent, only to realize it's true horror later on in the worst of moments.


答:
This would be a fairly trivial to implement (maybe 1 to 3 days total), so in my opinion its how much value its going to add to your application over its lifetime.

First, an alter table statement would be needed to add the columns, the alter table would all be the same (except for the table name), so you could write a script to code generate the alter SQL statement for all the tables this is needed.  Have to allow for NULLs to account for existing data and check for the existance of the columns so that it is re-runnable.

Second, for the columns, using default values, like GetUTCDate() (SQL Server, Oracle maybe different) solves any coding additions on insert, so the code base doesn't have to change for any of the inserts statements since default values will be used.

The updates to data (change to last modified) could be solved with an update trigger.  Again, this trigger would be nearly the same across all tables, so this trigger code (SQL) could be code generated as well for any existing tables.

There would be potentially a lot of sql script code (depending on how many tables), but it a pattern that is repeatable, so you could code generate it by looking at an existing DB schema.


问:
increasing productivity - mastering a language vs. selecting efficient tools
I'm looking for advice from experienced developers on this question.

In my work there's a need for a lot of one-off code. It's tempting to just dip into the right python/perl library calls to do these little tasks as quickly as possible.

I used to be of the philosophy of - "use most efficient tool for the task". However, I'm afraid that over time, this means that I won't have a deeper experience and expertise, so recently I've been forcing myself to use C++ (w/ Boost and STL) for everything, even if I could do the task in python or perl much more quickly. I'm hoping that in the long run, this will make me a more productive developer. I hope to reach a level of familiarity that I can do things in C++ as quickly as I can in python (and also have the practice to work on bigger projects that would require C++).

Is this a good strategy towards long-term productivity and deeper skills? Or am I unnecessarily wasting time / torturing myself?

答:
Or am I unnecessarily wasting time / torturing myself?

That's what you are probably doing.

A woodworker doesn't spend all day using a chisel to cut out shapes instead of a saw, does he? Programming languages are tools just like libraries and development environments. Writing a big C++ program to perform a job best handled by perl or grep is often a waste of time.

But, don't go overboard on the "best tool for a job" religion. A tool your are very familiar with and enjoy using may well exceed it's drawbacks compared to a "proper" tool that you don't enjoy using.


答:
... the more definitive statements a man makes the more likely he is to
  be definitively wrong ... - tyler durden

this applies to blanket "standards", while on some tables this could be a huge win, on every table it would most likely be useless noise and more code to maintain or forget to maintain.

there is a balance to be had here, that is what you should push to the decision makers.


问:
How Does A Compiler Work?
Note: I am surprised that this hasn't been asked before, and if it has I could not find it in a search.

I've been on tons of websites, I've read tons of articles, and I have heard tons of explanations. Most of them were good, but they were all either to broad or too complicated or just plain bad. So my question is , how does a compiler work?

If this is a difficult, broad question, please tell me. But if not, please answer the question.

答:
A compiler is a program that translates the source code for another program from a programing language into executable code.

The source code is typically in a high-level programming language (e. g. Pascal, C, C++, Java, Perl, C#, etc.).  The executable code may be a sequence of machine instructions that can be executed by the CPU directly, or it may be an intermediate representation that is interpreted by a virtual machine (e. g. Java byte code).

In short, a compiler converts a program from a human-readable format into a machine-readable format.

As to how a compiler works, that is indeed complicated.  There are books and university courses on the subject.  I will attempt to briefly outline the main stages of the process, but this will be a very cursory overview.

Lexing - break up the text of the program into "tokens". The tokens are the "words" of the programming language, such as identifiers (keywords, variable names, function names, etc.) or operators (=, *, &, etc.).

Parsing - convert the sequence of tokens into a parse tree, which is a data structure representing various language constructs: type declarations, variable declarations, function definitions, loops, conditionals, expressions, etc.

Optimization - evaluate constant expressions, optimize away unused variables or unreachable code, unroll loops if possible, etc.

Translate the parse tree into machine instructions (or JVM byte code).

Again, I stress that this is a very brief description.  Modern compilers are very smart, and, consequently, very complicated.

Title: How Does A Compiler Work?


答:
A compiler is a computer program (or set of instructions) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code). The most common reason for wanting to transform source code is to create an executable program.

Compilers bridge source programs in high-level languages with the underlying hardware. A compiler requires:

Determining the correctness of the syntax of programs

Generating correct and efficient object code

Run-time organization

Formatting output according to assembler and/or linker conventions.

Title: How Does A Compiler Work?

Body:
Note: I am surprised that this hasn't been asked before, and if it has I could not find it in a search.

I've been on tons of websites, I've read tons of articles, and I have heard tons of explanations. Most of them were good, but they were all either to broad or too complicated or just plain bad. So my question is , how does a compiler work?

If this is a difficult, broad question, please tell me. But if not, please answer the question.


答:
I thinks devs often find the grass greener on the other side. There isn't much that can't be theoretically be accomplished in either environment. But, the strengths of C++ become clearer when dealing with performance-intensive problems, while the strengths of scripting become clearer when dealing with breadth-first implementation. At some point, the productivity curves meet, and switchover to C++ makes its case.

Also, C++ is the lingua franca of development for historical reasons, and obviously C++ talks best with C++, so you're likely to encounter it frequently.

Finally, learning both sides is great for perspective, which generally makes one a more versatile and informed developer. So, I think improving your C++ would be a very productive thing for you, and learning something like Python (or Perl, etc) is a great thing for C++ developers to know.

Title: increasing productivity - mastering a language vs. selecting efficient tools

Body:
I'm looking for advice from experienced developers on this question.

In my work there's a need for a lot of one-off code. It's tempting to just dip into the right python/perl library calls to do these little tasks as quickly as possible.

I used to be of the philosophy of - "use most efficient tool for the task". However, I'm afraid that over time, this means that I won't have a deeper experience and expertise, so recently I've been forcing myself to use C++ (w/ Boost and STL) for everything, even if I could do the task in python or perl much more quickly. I'm hoping that in the long run, this will make me a more productive developer. I hope to reach a level of familiarity that I can do things in C++ as quickly as I can in python (and also have the practice to work on bigger projects that would require C++).

Is this a good strategy towards long-term productivity and deeper skills? Or am I unnecessarily wasting time / torturing myself?


问:
Does Java promote a separation between class definitions and implementations, as is  C++?
I have a homework assignment and I need to evaluate which approach is better according to GRASP "Protected Variation". I found a question on Stack Overflow about the separation of header and code files in C++.

However, what I want to know why Java does not follow C++ in promoting the separation between class definitions and class implementations. Are there any advantages with the Java method, over the C++ method?

答:
Java has interfaces to define a contract.  This gives a higher level of abstraction from what the caller needs and the actual implementation. i.e. the caller doesn't need to know the implementing class, it only needs to know the contract it supports.

Say you want to write a method which slows all the key/values in a Map.

```<code>public static <K,V> void printMap(Map<K,V> map) {
    for(Entry<K,V> entry: map.entrySet())
        System.out.println(entry);
}
</code>```

This method can call entrySet() on an abstract interface which is removed from the class implementing it.  You can call this method with.

```<code>printMap(new TreeMap());
printMap(new LinkedHashMap());
printMap(new ConcurrentHashMap());
printMap(new ConcurrentSkipListMap());
</code>```

Body:
Java has interfaces to define a contract.  This gives a higher level of abstraction from what the caller needs and the actual implementation. i.e. the caller doesn't need to know the implementing class, it only needs to know the contract it supports.

Say you want to write a method which slows all the key/values in a Map.

public static <K,V> void printMap(Map<K,V> map) {
    for(Entry<K,V> entry: map.entrySet())
        System.out.println(entry);
}

This method can call entrySet() on an abstract interface which is removed from the class implementing it.  You can call this method with.

printMap(new TreeMap());
printMap(new LinkedHashMap());
printMap(new ConcurrentHashMap());
printMap(new ConcurrentSkipListMap());


答:
You're getting really good answers here.
The stack* forums are an excellent source of information.

While each language has performance tricks, the key to good performance is simplicity of design.
Then, after the software is running (not when you're coding) deal with performance.
It's unproductive to go eyeballing code and guessing if you should use trick X in location Y.
Let the actual running program tell you what to fix.
(Everybody knows that, but they still use the ready-fire-aim method.)
If you learn this technique for performance diagnosis, you will find it useful, as have many others.

Basically, you interrupt the program at random several times, and each time understand in detail what it's doing.
Don't skim.
Understand what it's doing and why.

If you see it doing something twice, no matter how you describe it, that activity is taking significant time.
The sooner you see it, the more significant it is.

Technically, if some activity is consuming fraction p of time, the average number of samples you need before you see it twice is 2/p.
So if p is 20%, on average it will take 10 samples to see it twice.
(Technically, this comes from the negative binomial distribution, where if a coin has fairness p, the number of tails you will get before x heads is, on average, x(1-p)/p.)

The point of this approach is that, rather than measuring various things and hoping to narrow in on some problem code, it shows you the problem in crystal-clear detail, even if it's not localized to a particular piece of code.
It can find problems you can't find any other way.


问:
Analyzing a programming language
In SICP, the authors state (Section 1.1) that there are three basic "mechanisms" of programming languages:

primitive expressions, which represent the simplest entities the language is concerned with

means of combination, by which compound elements are built from simpler ones

means of abstraction, by which compound elements can be named and manipulated as units

How can I analyze a mainstream programming language (Java, for example) in terms of these elements or mechanisms?

答:
Rough stab:

Expressions are just that; what constitutes an expression in Java. I don't know if that would expand to include statements or not.

Combinations would include compound expressions, (variables?,) statements, methods, the class mechanism, and packages. Modules, too, once they're in the language.

In Java, the simplest means of abstraction is a class: nothing may exist outside of a class. There are, perhaps, "layers" of abstraction: a static method is arguably simpler than an instance method, because it doesn't require an instance.

Generics offer an additional layer of abstraction (and frustration).

Title: Analyzing a programming language

OwnerDisplayName: Dave Newton


答: Based on the lack of actual answers, you might want to build the site you were looking for.  It's fairly easy to make the simple performance comparisons you described and put them into a blog.  If you want others to be able to provide input, you could encourage Stack Exchange to add a performance.StackExchange.com site, or you could build a similar site yourself.</p>


问:
What's wrong with circular references?
I was involved in a programming discussion today where I made some statements that basically assumed axiomatically that circular references (between modules, classes, whatever) are generally bad.  Once I got through with my pitch, my coworker asked, "what's wrong with circular references?"

I've got strong feelings on this, but it's hard for me to verbalize concisely and concretely.  Any explanation that I may come up with tends to rely on other items that I too consider axioms ("can't use in isolation, so can't test", "unknown/undefined behavior as state mutates in the participating objects", etc.), but I'd love to hear a concise reason for why circular references are bad that don't take the kinds of leaps of faith that my own brain does, having spent many hours over the years untangling them to understand, fix, and extend various bits of code.

Edit: I am not asking about homogenous circular references, like those in a doubly-linked list or pointer-to-parent.  This question is really asking about "larger scope" circular references, like libA calling libB which calls back to libA.  Substitute 'module' for 'lib' if you like.  Thanks for all of the answers so far!

答:
Some garbage collectors have trouble cleaning them up, because each object is being referenced by another.

EDIT: As noted by the comments below, this is true only for an extremely naive attempt at a garbage collector, not one that you would ever encounter in practice.

Title: What's wrong with circular references?


答:
A programming language is generally defined by its syntax and its semantics.  Both of these will be defined in the standards for the language.

The syntax outlines how to write a valid program and the semantics defines what that valid program means.

In your cases, the syntax will tell you what your primitives are, how you combine them, and how you abstract them.   The semantics will tell you what the combinations and abstractions mean.

For example, the syntax will tell you how to write a valid for loop.  The semantics will tell you what the for loop does.

If you really want to start to analyze a programming language, grab a copy of the standard and see what is in there.  I would really start off with a simple language, like C, before delving into Java.  I would also read the rest of the book.  Learning why programming langauges work the way they do has made me a better programmer, even though I don't implement compilers.

Title: Analyzing a programming language

Body:
In SICP, the authors state (Section 1.1) that there are three basic "mechanisms" of programming languages:

primitive expressions, which represent the simplest entities the language is concerned with

means of combination, by which compound elements are built from simpler ones

means of abstraction, by which compound elements can be named and manipulated as units

How can I analyze a mainstream programming language (Java, for example) in terms of these elements or mechanisms?


答:
Headers are there to enable separate compilation.  By #including the headers, the compiler doesn't need to know anything about the binary structure of compiled C++ code, and can leave that job to a separate linker.  Java does not use a separate linker with its compiler, and since .class files are strictly defined, the compiler is able to read them to determine all their members with all their types, without any need to re-declare them in each compilation unit.

You can include all the implementation in a C++ header, but it causes the compiler to recompile it every time it's #included, forcing the linker to sort out and discard the duplicate copies.

Title: Does Java promote a separation between class definitions and implementations, as is  C++?

Body:
I have a homework assignment and I need to evaluate which approach is better according to GRASP "Protected Variation". I found a question on Stack Overflow about the separation of header and code files in C++.

However, what I want to know why Java does not follow C++ in promoting the separation between class definitions and class implementations. Are there any advantages with the Java method, over the C++ method?


答:
Hmm... that depends on what you mean by circular dependence, because there are actually some circular dependencies which I think are very beneficial.

Consider an XML DOM -- it makes sense for every node to have a reference to their parent, and for every parent to have a list of its children. The structure is logically a tree, but from the point of view of a garbage collection algorithm or similar the structure is circular.

Title: What's wrong with circular references?

Body:
I was involved in a programming discussion today where I made some statements that basically assumed axiomatically that circular references (between modules, classes, whatever) are generally bad.  Once I got through with my pitch, my coworker asked, "what's wrong with circular references?"

I've got strong feelings on this, but it's hard for me to verbalize concisely and concretely.  Any explanation that I may come up with tends to rely on other items that I too consider axioms ("can't use in isolation, so can't test", "unknown/undefined behavior as state mutates in the participating objects", etc.), but I'd love to hear a concise reason for why circular references are bad that don't take the kinds of leaps of faith that my own brain does, having spent many hours over the years untangling them to understand, fix, and extend various bits of code.

Edit: I am not asking about homogenous circular references, like those in a doubly-linked list or pointer-to-parent.  This question is really asking about "larger scope" circular references, like libA calling libB which calls back to libA.  Substitute 'module' for 'lib' if you like.  Thanks for all of the answers so far!


答: The only way to truly master a language is to use it regularly on real projects.  Forcing yourself to use a language for one-offs is great when you are enthusiastic about it, but the novelty usually wears off before you really achieve mastery.  Not that just being "familiar" with a language isn't useful in and of itself.</p>


问:
Can freelancers ask their client to sponsor an iPad for project needs?
I do freelance web projects for a client.  The client has been asking me to buy an iPad for testing purposes. Should I ask him to get me an iPad ?

I otherwise don't have any need for the iPad. Is it ethical to ask for sponsorship when you are getting paid for the projects ? Should I try it out ?

答:
Although this doesn't address your direct question. If it's a web-based project, I will add a cent.  For simple Ipad and multiplatform device screenshots and basic interactivity testing I have used CrossBrowserTesting.com with success. You can generate screenshots and send them to your client quickly and easily so it may even be helpful if you have an ipad. </p>

<p>*Other than being a customer I have no interest or affiliation with crossbrowsertesting.com</p>

Body:
Although this doesn't address your direct question. If it's a web-based project, I will add a cent.  For simple Ipad and multiplatform device screenshots and basic interactivity testing I have used CrossBrowserTesting.com with success. You can generate screenshots and send them to your client quickly and easily so it may even be helpful if you have an ipad.

*Other than being a customer I have no interest or affiliation with crossbrowsertesting.com


答:
The larger question here is not the cost of buying a ipad but the cost of making your project work on an iPad.

Before you do anything you need to estimate the cost of building in iPad compatibility (you might have to borrow one to do this). If it's just and hour or two of work than, no it's probably not reasonable to have your client fork over $600 for the device. If you see a very sizable ipad compatibility development bill then you may find it more appropriate to pay for the ipad yourself and then work the cost of the depreciation of the ipad into the bill.

In other words if it's $300 worth of work, no don't buy and ipad. If it's $5000 of work, yes, buy a used ipad with the deposit money and sell it when your done. This way it only cost the client $100 or $200 at most. This seems the most fair and builds more value into what you offer by delivering on the clients needs.

Title: Can freelancers ask their client to sponsor an iPad for project needs?

Body:
I do freelance web projects for a client.  The client has been asking me to buy an iPad for testing purposes. Should I ask him to get me an iPad ?

I otherwise don't have any need for the iPad. Is it ethical to ask for sponsorship when you are getting paid for the projects ? Should I try it out ?


问:
Collaborate on UML online
Some friends and I are starting up a hobby programming project.
I wonder if there is any good method/tool/service which lets us collaborate on UML diagrams online.
This can be in any form (online direct edit, source-control style, etc.) as long as we can make changes independent of each other.</p>

答:
It is difficult to create a CASE tool that allows different users to change things simultaneously.

In the past, Texas Instruments created IEF that is a repository based tool based on batch check-out and check-in process. A similar product ERWin also uses a repository for storing the model meta data. None used the collaborative style. The challenge is to handle conflicting user interactions, for example one user may be defining a proper in a class while the other user attempts to delete or rename the class either in the same diagram or in another one.

Also, it is generally good idea to have one person in charge of a diagram. Ideas are welcome but final implementation should be a single person's responsibility unless the model is well divided into separate parts.

Title: Collaborate on UML online


答:
I'd answer that question with another question:

What situation can you give me where keeping a circular reference model is the best model for what you're trying to build?

From my experience, the best model will pretty much never involve circular references in the way I think you mean it.  That being said, there are a lot of models where you use circular references all the time, it's just extremely basic.  Parent -> Child relationships, any graph model, etc, but these are well known models and I think you're referring to something else entirely.

Title: What's wrong with circular references?


问:
Backtrack My "Education"
A while ago, I decided to start programming. I really, just jumped into a language (Perl) and went from there. What I regret is that I just jumped in:

I didn't learn the basics (if you would call them basics).

I didn't learn about Computer Science.

This issue, I believe, is holding me back from my true potential. Where should I "restart"? Are there any books, articles, etc. that I should read? Are there any topics an experienced programmer should know? What's your advice?

答:
Well, I started out for the same reason as I had some knowledge on the hardware side and was intrigued with programming. I like to learn new things.

I started with DOS Batch files, then QuickBasic, then Visual Basic, VBA, MASM, with Access for database work before landed my first job.  For me, that was the best path, starting simple and then building from there.

I would say decide what you like best about programming and go with that route, scripting, web development, windows programming, etc... If you don't know, then start working with some languages to see what you like.  You will need time though.  It takes about 5 years to get really good with a language like Java or maybe C++, IMHO.

As a language to help learn web development, JavaScript definitely, PHP is popular, and Python, but that is IMHO.  It's assumed you will know or learn HTML/CSS.  I really underestimated javascript, even though I've used it since 2001.  I did the same thing with CSS and didn't think it was important.  I've changed my opinion on that as well.

When I try to determine a trend, I go to
http://www.indeed.com and click on the trends link in the upper left part of the page. Then I put in keywords like PHP and Python and see which are being put down for actual job positions that are out on the internet.

This is from a career perspective though and based on what brings me the most value to the clients (employers). Not just from a learning perspective.

Title: Backtrack My "Education"


问:
Should a programmer fix someone else's failed build?
One programmer committed some work to the SVN repository, then went home. After he left, the Hudson automatic build failed. Another programmer saw this, and after looking through the code changes, detected that the problem was the absence of one library. He added this library to SVN and the next build completed successfully.

Did the second programmer do the right thing or should he have just waited until the first programmer fixed the issue?

答: Yes yes yes! It fosters collective code ownership and sets a kind of healthy peer-pressure in the team to keep a high standard and not let a broken window scenario develop. A bit of communication to let the other developer know is a good idea.</p>


答:
I think it's OK to fix obvious things - i.e., if you are 100% sure the guy whose code you're fixing would make the same - or substantially the same - fix. If the fix is more complex, it is usually polite to talk to the person whose code you're fixing - it may be that you misunderstood the intent or the reason for breakage is not what you thought it is, or maybe he intended another fix but for some reason couldn't commit it just yet (life happens, you know :).

In general, the rule usually is: you break the build - you fix the build, but there are exceptions, especially if the fix is obvious and/or the person responsible is unreachable.

Of course, if you have the case of serial build breaker - especially with the pattern "checked in, went home, build broken for days" - the responsible person needs to get some talking to about why CI systems and tests exist and how one should check before checking in :)

Body:
One programmer committed some work to the SVN repository, then went home. After he left, the Hudson automatic build failed. Another programmer saw this, and after looking through the code changes, detected that the problem was the absence of one library. He added this library to SVN and the next build completed successfully.

Did the second programmer do the right thing or should he have just waited until the first programmer fixed the issue?


问:
Parameter order: size, count or the other way round
I hope this is the right forum for this ... Well, in C, the standard library uses usually (void* buffer, int size) when referring to some data buffer. I wonder if there is a rationale for this order instead of (int size, void* buffer). I couldn't think of any good reason, and it seems to be an arbitrary choice, but I'm curious to here if there is some deeper meaning behind this order.

答:
Generally you prefer the data parameters first and then the const values.
There is also a preference for the result first  eg strcpy(dest,src)  memcpy(dest,src)

In c++ it's useful because you can have default parameters at the end.


问:
How large is ok for a Class?
I’m a long time developer (I’m 49) but rather new to object oriented development. I’ve been reading about OO since Bertrand Meyer’s Eiffel, but have done really little OO programming.

The point is every book on OO design starts with an example of a boat, car or whatever common object we use very often, and they start adding attributes and methods, and explaining how they model the state of the object and what can be done with it.

So they usually go something like "the better the model the better it represents the object in the application and the better it all comes out".

So far so good, but, on the other hand, I’ve found several authors that give recipes such as “a class should fit in just a single page” (I would add “on what monitor size?" now that we try not to print code!).

Take for example a PurchaseOrder class, that has a finite state machine controlling its behavior and a collection of PurchaseOrderItem, one of the arguments here at work is that we should use a PurchaseOrder simple class, with some methods (little more than a data class), and have a PurchaseOrderFSM “expert class” that handles the finite state machine for the PurchaseOrder.

I would say that falls in the “Feature Envy” or “Inappropriate Intimacy” classification of Jeff Atwood's Code Smells post on Coding Horror. I’d just call it common sense. If I can issue, approve or cancel my real purchase order, then the PurchaseOrder class should have issuePO, approvePO and cancelPO methods.

Doesn’t that goes with the “maximize cohesion” and “minimize coupling” age old principles that I understand as cornerstones of OO?

Besides, doesn’t that helps toward the maintainability of the class?

答:
I'm with the OP on the Feature Envy classification.  Nothing irritates me more than having a bunch of classes with a bunch of methods that work on some other class's internals.  OO suggests that you model data and the operations on that data.  That doesn't mean that you put the operations in a different place from the data!  It's trying to get you to put the data and those methods together.

With the car and person models so prevalent, it'd be like putting the code for making the electrical connection, or even spinning the starter, into the person class.  I would hope that this would be obviously wrong to any experienced programmer.

I don't really have an ideal class or method size, but I prefer to keep my methods and functions fitting on one screen so that I can see their entirety all in one place.  (I have Vim configured to open a 60-line window, which happens to be right around the number of lines on a printed page.)  There are places where this doesn't make a lot of sense, but it works for me.  I like to follow the same guideline for class definitions, and try to keep my files under a few "pages" long.  Anything over 300, 400 lines starts to feel unwieldy (mostly because the class has started taking on too many direct responsibilities).

Title: How large is ok for a Class?