答:
You'd need to perform the checking asynchronously - ie when an item is added to the cart, you fire off a request but do not wait for the response. Instead all responses go to a central queue and are then applied to the cart.

If an item is out of stock, then you will have to notify the user as they browse the site, possibly pop up a warning saying the item is unavailable. They will have an item in their cart with a red warning when they look. You could then cache the results and remove that item from the store (or mark it as temporarily unavailable) and intermittently re-check to see if the item has been restocked.

Also, when they reach the checkout area, you will have to pause while the queue empties and each item in their cart receives their check response.

It depends on your situation whether this will work well - if there are a lot of 'sold out' stock then this is probably not what you want to do, but in such a case, you will have no option but to wait for the response.

Title: Patterns for integrating with a slow external service

Body:
Was hoping someone could provide some patterns/techniques/ideas to increase performance for the following scenario.

Am integrating with an external ordering system via SOAP. The external system can be slow and unfortunately nothing can be changed at that end.

All products are retrieved from this external source and an order is only placed with the external system when they've paid so cart functionality will be implemented locally.

When a item is added to the cart, it will check the external source if there's enough stock and then add the item to the cart locally, and the user will stay on the same page (eg. wont' redirect to a cart summary screen). It will also check the rest of the items in their cart to ensure there is enough stock, so depending on how many items they have there could be a lot of calls to the external source.

I guess, could only check the stock levels for other items in their cart when they get to the checkout summary screen and subsequent checkout screens but i feel that isn't the best user experience.

For reference, local site will be using ASP.NET MVC3

Any suggestions?

Thanks


问:
How can I satisfy this project requirement?
I'm part of a two-person team that is building a web-based virtual tour application with specific extra functionality that doesn't exist in current applications.  This is a summer school project.

The team lead wants this application to be as platform and dependency-agnostic as possible.  To do this, we're using Google's Fusion Tables and StreetView APIs to display the images and serve as a database.  This way, a client installing this application on their server doesn't have to worry about configuring and maintaining a local database and all that is necessary on their end is a Google Apps account and the images themselves.

My issue is how does the client make requests for images and data without a server-side language?  Most, if not all of the data will be textual, and thus be able to render as JSON and parsed as such.  However, that leaves the issue of the images themselves.  They will be hosted on a to-be-determined location, and I need some way to access them.

Using Ajax, I can execute a PHP call to load an image easily, and I already know how to do this.  Its been suggested that I use the Java client library to interface with GData services, but I think this is overcomplicating things.

My arguments for including PHP as an application requirement are

PHP is synonymous with hosting.  I've yet to run across a commercial host that doesn't offer PHP

I already know how to implement the Ajax calls to the PHP function.

As this application has a 6 week deadline, I'd like to stick with what I know rather than learning a whole new methodology

His arguments for looking somewhere else are

No guarantee that PHP will be loaded on the server to be used.  Our school's CMS is based in Java, and PHP is not installed

Java is a standard inclusion in server and client configruations

The application should be server and dependency agnostic in the sense that it can be uploaded to a folder and accessed without any configuration

Honestly, if I had the time, it would be an interesting side project to include this type of functionality, especially since I've never done it before and it sounds interesting.  But I keep thinking about that 6 week deadline, and as I'm the one that will be doing the majority of the coding, I just don't think I can do it in time without PHP.

答:
You can't be platform and dependency agnostic as possible, and then demand Java be used.

If I were you, I'd push the issue back on him and explain the situation, he should either provide you with sample code to do this (at least) or go with the tooling that you already know. Trying to shoehorn training and development into a short deadline doesn't go. If he cannot do either, then inform him you cannot do it and he should find a java engineer.

Ps. Java is not a standard inclusion on all clients, many people won't bother installing it so you cannot depend on it being there. Javascript on the other hand will be present in all but the most primitive browsers.

PPS. the way the browser grabs images is very simple: you need a web server that holds the images as static files (gninx is good for this), then you just request them as http urls inside your html page that you're displaying in the browser.

ContentLicense: CC BY-SA 3.0


问:
Stick with custom or migrate to CMS?
I have a site that has been built from scratch by a few different programmers over time. The first programmer, who built the initial system and database, was not very tech savvy.  Other programmers who worked later also did things their own way, taking shortcuts, patching things instead of dealing with root cause issues, as a result I got a website which is buggy and unmaintainable.

The site is made for wholesale distributors who come to buy and sell products.  They register an account and take advantage of premium features. There is quiet a bit of different things that go on  under the hood, for example, to stop fraudsters to continuously registering new accounts, we automatically block their account if any of the previous info they registered with is matched with their new registration info.  We also have robot call and verify their phone number.

We also developed a system where anyone can send an email to our designated email address, and their email body and subject contents get posted as a buy and sell ad.

I want to rebuild the site.  I've been thinking that in order to prevent future problems associated with programmers doing things their own way, it is good to migrate the whole site to a CMS such as Drupal or Wordpress and rebuild other features in the form of plugins.  That way I suspect, the core, the framework, of the site will remain untouched by programmers, and every time core CMS updates come out, my site remains up-to-date.  what do you think? Is this a good idea?  Or should I keep the site custom but hire a savvy programmer who could try to fix all the problems, optimize PHP and Database.

I also would like to know if migrating my site and database is going to be expensive?

答:
This is a really good question, but I feel it is perhaps to localized. We struggle with this question all the time in IT: build or buy ? And if we build, what do we start with? The answer is, "it depends".

How good of a fit is a CMS to your business domain? Your website doesn't really sound like a traditional content site to me, but if it is then what you might do, is just setup your own little copy of Drupal (or whatever) and start prototyping - sketching out -  out how you would build the site with it - what are the gaps you need to fill with custom plugins (put some static placeholder there). Practice doing some workflows with your prototype. This will be well worth your time, and I think you'll be able to answer your own question after doing it.

The second part of your question "hire a savvy programmer" - well that's really the hard part isn't it? Here's the thing: no one wants to fix your crappy website. Anyone who you can find to do it, is either going to try and convince you to let them build The Next Great System (their way) - or they are just doing time because they couldn't find any better job to do. Even someone smart and conscientious isn't going to get inspired by the prospect of doing this.

Title: Stick with custom or migrate to CMS?


问:
What do I need to do to NOT steal "Hello World" code with a GPL license?
In the project, I found a file, math.c, with a big GPL header and ...

```<code>//------------------------------------------------------------------------------
/// Returns the minimum value between two integers.
/// \param a  First integer to compare.
/// \param b  Second integer to compare.
//------------------------------------------------------------------------------
unsigned int min(unsigned int a, unsigned int b)
{
    if (a < b) {
        return a;
    }
    else {
        return b;
    }
}
</code>```

OK, cool so I need to get min value and ... this file!? So I need to open the whole project because of it? Or do I need to reinvent mathematics?

I don't believe it's just insane, so the question is: when we can just remove the GPL header?

Must I be a weirdo and do it?:

```<code>unsigned int min(             unsigned int
JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE,
unsigned int hyrthrtRERG            ) {  if
(JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE
< hyrthrtRERG            ) {  return JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE;  }
else {return hyrthrtRERG            ;    } }
</code>```

Seriously, do they want me to write code like the above?

答:
If you're using C++ and not C, sidestep this issue by using the standard library std::min or std::max in <algorithm>:

http://www.cplusplus.com/reference/algorithm/min/

That buys you generality, and it will work for any comparable type.  Also: when whatever d-bag tries to claim they invented it and is covered by software patents, they'll be rumbling with the ISO committee...not you.

In the general case, take note of who published the code.  Corporation, or sane individual?  If it's a sane individual (as is the case with much open source), write a nice note to them and get permission.  Save their response saying it's okay.  Problem solved.


问:
Monopoly game 3D graphical interface
I have created a Monopoly game with a 2D Graphics in Java for my final exam at college.

I feel that the game doesn't look very good and I want to add a 3D Graphics. My problem is that I have never done 3D programming and I don't know how to create 3D objects.

Can someone tell me where can I create 3D objects and what library to use for 3D programming that will allow me to create a 3D graphic interface fast? I have only two more weeks to do this. Can this be done?

答:
3D graphics is hard, and 2 weeks is a short amount of time. You have been warned. But it can be done if you are very dedicated and eager to learn!

Firstly you will need a 3D engine or library. For Java, the best 3D engine IMHO is jMonkeyEngine. It would allow you to build a scene by positioning and moving objects in 3D space. There are a lot of demos / example code on the site to explore. Another option is LWJGL which gives you more direct access to OpenGL calls - but this is more low level so probably more tricky for a first-timer.

You will also need to build 3D assets (graphics, models etc.). I actually think this might be harder than setting up the 3D engine itself, since it can take a lot of work to produce a large volume of decent 3D assets. There are some amazing open source tools available like Blender - but this can take as long to learn as 3D programming itself! On the plus side, you may however be able to re-use some of your 2D graphics as textures on 3D objects.

Finally, you will need to do some coding to make your 3D interface. There will be a few things to do here:

Render in 3D space rather than in 2D - all your objects will need (x,y,z) positions rather than just (x,y)! But also you will need to consider rotations, camera angles etc.

Modify your user interactions / input interface. In 2D, handling mouse clicks is relatively easy. In 3D, you have a slightly more complex problem figuring out what the user clicked on!

Add nice "3D touches". e.g. you could animate the dice rolls in 3D

Overall seems like a big project - but you will learn a huge amount so don't let that put you off!

If you are concerned about how much you can achieve, I would suggest trying to replicate your 2D version as closely as possible in the 3D engine at first (overhead view, flat square objects). Once you get this working, you can think about the more complex stuff (rotating the view, lighting, complex 3D models etc.)

Title: Monopoly game 3D graphical interface


答:
Just write it yourself in 30 seconds. You can use exactly the same algorithm. Just don't copy/paste.

Copyright only protects the expression of an idea, not the idea itself. You can use the idea directly providing you don't copy it.

FWIW, I doubt that copying such a trivial piece of code would get you into trouble anyway. Damages would be zero, and it would probably fall under fair use in most jurisdictions. But  legal cases are such a pain that I wouldn't want to risk it.

Title: What do I need to do to NOT steal "Hello World" code with a GPL license?

Body:
In the project, I found a file, math.c, with a big GPL header and ...

```<code>//------------------------------------------------------------------------------
/// Returns the minimum value between two integers.
/// \param a  First integer to compare.
/// \param b  Second integer to compare.
//------------------------------------------------------------------------------
unsigned int min(unsigned int a, unsigned int b)
{
    if (a < b) {
        return a;
    }
    else {
        return b;
    }
}
</code>```

OK, cool so I need to get min value and ... this file!? So I need to open the whole project because of it? Or do I need to reinvent mathematics?

I don't believe it's just insane, so the question is: when we can just remove the GPL header?

Must I be a weirdo and do it?:

```<code>unsigned int min(             unsigned int
JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE,
unsigned int hyrthrtRERG            ) {  if
(JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE
< hyrthrtRERG            ) {  return JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE;  }
else {return hyrthrtRERG            ;    } }
</code>```

Seriously, do they want me to write code like the above?


问:
Good workflow for software development with scrum and continuous integration
I'm studying an approach to understand better how the continuous integration workflow fits better in a software development company with the scrum method.

I'm thinking something like this:

Would that be a nice workflow?

答:
Conceptually yes.  A diagram isn't capturing a lot of important points though like:

unit testing

incremental commits

staging gets deployed to often, production usually doesn't.


问:
When should you call yourself a senior developer?

Possible Duplicate:

  Whats the difference between Entry Level/Jr/Sr developers?

I'm curious what senior developer means because apparently the definition doesn't mean what I thought it would. I keep seeing these teens at 22-23 years old who call themselves senior X developer or senior Y developer. To me, a senior must have 10 years or so experience in programming to call himself 'senior'. I've seen a lot of these teens here (hence the question). Am I wrong? Why?

答:
you're missing the point.

Senior means nothing. Junior means nothing. Titles mean nothing. My title - Associate Business Systems Director. My responsibilities - managing all things IT from in house software development through to infrastrucure, through security, through to customer web sites. My software development experience - self taught. My network experience - self taught. My overall cabapilities in the IT field - worse than yours.

My ability to manage and direct - debateable, but my character and personality got me the job and makes me succesful at it.

Titles mean nothing ability and effort means everything. I'm not the best - and to believe so would be arrogant.

Forget your hang ups about titles and prove your worth!


答:
As its GPL code the big question here is are you planning distrubute your code or sell your software.

If you are just using it internally the GPL gives you complete freedom to do as you wish.

If you are planning to distribute you package -- the easiest thing is to GPL your package on the same terms as any GPL source you used. There are other ways but it gets complicated.

If you are planning to sell your software, you must distribute the source code for any GPL code you used and/or amended under the same GPL license by which you obtained it.


答:
It sounds to me like your situation is exactly when you wouldnt rely on a CMS.  You have a service - its the core product that you produce.  If you used a CMS, virtually every part of it will be customized.  You're not going to be able to simply swap in a new version of the CMS once all thats in place.  It'd be better over the long run not to have to fight with an external framework to make otherwise simple changes, and not put your company at risk if the framework is discontinued or has a significant security or other problem that cant easily be upgraded because you've customized it so much.

From what you describe, your problem isnt the lack of a CMS - its the lack of a clear development vision and proper management of development resources.  If you dont get that straigntened out and just start implementing a CMS, you'll probably just end up with a mish-mash of CMS's and other frameworks after a couple of years as everyone's still going to do their own thing, and your system will be even more complicated to maintain.

Title: Stick with custom or migrate to CMS?

Body:
I have a site that has been built from scratch by a few different programmers over time. The first programmer, who built the initial system and database, was not very tech savvy.  Other programmers who worked later also did things their own way, taking shortcuts, patching things instead of dealing with root cause issues, as a result I got a website which is buggy and unmaintainable.

The site is made for wholesale distributors who come to buy and sell products.  They register an account and take advantage of premium features. There is quiet a bit of different things that go on  under the hood, for example, to stop fraudsters to continuously registering new accounts, we automatically block their account if any of the previous info they registered with is matched with their new registration info.  We also have robot call and verify their phone number.

We also developed a system where anyone can send an email to our designated email address, and their email body and subject contents get posted as a buy and sell ad.

I want to rebuild the site.  I've been thinking that in order to prevent future problems associated with programmers doing things their own way, it is good to migrate the whole site to a CMS such as Drupal or Wordpress and rebuild other features in the form of plugins.  That way I suspect, the core, the framework, of the site will remain untouched by programmers, and every time core CMS updates come out, my site remains up-to-date.  what do you think? Is this a good idea?  Or should I keep the site custom but hire a savvy programmer who could try to fix all the problems, optimize PHP and Database.

I also would like to know if migrating my site and database is going to be expensive?


答:
Have you looked into Joomla?, you can just create a new component in it's application space and toss the code in there with a few additions (point of entry and make sure all URLs are correctly generated) and have the sucker working.

Of course you might want to rewrite it and you can do so with it's application framework, but the important part is you can do so gradually and that you will benefit from the CMS.

But, independently of the platform (which could just be an application framework like Symfony), do you have any sort of migration plan?

Title: Stick with custom or migrate to CMS?


答:
Full-disclosure: my primary expertise is in client-side work and I actually take pride in having JavaScript expertise. I've been exposed to a wide variety of stuff over the last four years (two of them were mostly short-term contracts with interactive agencies dealing with all manner of different web solutions) but take my opinions in light of this fact.

First of all Drupal is horrid. Really bad. It appeals to people who don't like writing code. Guess who maintains it? It is a royal PITA on the front end and taking a peak under the hood at the underlying PHP was like staring into the abyss. And I don't even know PHP that well. I've tried to have an open mind to both Drupal and also Joomla over the years but every experience has been misery on the client-side and not much fun on the back-end from what I could observe. If that doesn't sound very objective it's because it's not. I've worked with it. I freaking hate it.

A good CMS (I haven't really met one that I loved to be honest) might be helpful to you but they tend to be more about plug-in solutions that aren't very flexible or that have zillions more options than you need but none of the exact 2-3 ones you might want. I think choosing a smart generalist back-end framework might be the  best way to go. WordPress is well-regarded but that might be because it's the only one that tends to maintain its own scope as a CMS.

After all, the point of a CMS is more to provide minimal-skill-editing of content on primarily content sites. Some, like Drupal promise much, much more but deliver a very enthusiastic community that knows absolutely nothing. In your case, certainly your site has content but it's not what I would tend to think of as a 100% content driven site. You have an app site or at least enough app to consider it so. Go with a back end framework that helps devs build and maintain apps.

I'm personally particularly fond of Django because it takes what I consider the ideal middle-ground. It will get out of your way when you need it to but the vast majority of stuff works so well and is flexible and fast and easy enough in its own right that you're still going to tend to want to do things consistently and in line with the framework's general philosophy. It's also a Python framework. And it assumes you can handle regular expressions. Django devs aren't people who hope to never have to learn anything new about development after college.

Python, IMO, and I'm not talking about the very best devs - so no holy war intended, is also going to tend to attract higher quality devs at the jr and mid-level. Or perhaps it makes more sense to say that it's going to alienate the crappy ones for not having a C-based syntax and offering flexibility that tends to horrify a certain kind of app dev who should probably stay away from the web.

The other general framework I've worked with that's tended to be the most painless has been .NET MVC, which was not easy for me to admit the first time I realized it. I'm not a hater but for your needs I would not recommend Rails. PHP might have something good in the mix that's even specifically targeting your needs but it could be a long search, and I despise Java too much to give an honest, unbiased appraisal, except to say that people who know why Java tends to make me want to kick puppies even though I'm totally cool with C, swear Spring is different.

You might also want to poke around and see if there are frameworks that cater more specifically to needs like yours. You never know. See what the competition or similar-minded businesses are doing.

Title: Stick with custom or migrate to CMS?


答:
As well as these great answers here, you could also enhance your game graphics via a simplified form of 3D graphics, which may not require as much work as using a 3D game engine using full perspective would. I'm talking here about Isometric graphics - which are also known as 2.5D and oblique projections. You can think of it as a simple projection of your 2D board into 3D space. Not sure how much you could do in 2 weeks however.

Here is an example of a chess board and pieces in isometric:

Title: Monopoly game 3D graphical interface

Body:
I have created a Monopoly game with a 2D Graphics in Java for my final exam at college.

I feel that the game doesn't look very good and I want to add a 3D Graphics. My problem is that I have never done 3D programming and I don't know how to create 3D objects.

Can someone tell me where can I create 3D objects and what library to use for 3D programming that will allow me to create a 3D graphic interface fast? I have only two more weeks to do this. Can this be done?


问:
Design patterns: moving object references around an application
I'm new to Programmers and I am looking to increase my knowledge of programming. Recently, a user on Stack Overflow told me using singletons is a bad idea, that they encourage tight coupling and that they make testing harder.

What prompted this discussion was that every class I've ever written accessed any kind of data through a singleton. For example, a class that handles state data for a game. If any other class wanted to access this data, all they would have to do is get the singletons instance and there it would be. Specifically, instantiating a class on the AppDelegate, then accessing it via: [[[[UIApplication sharedApplication] delegate] gameObject] getScore].

The SO user told me that I should instantiate the 'gameObject' wherever I first need it, then pass that object to every other class that needs it via either a method as an argument, or via a property.

I was discussing these points when someone else pointed out that this information is completely wrong, that singletons are unrelated to coupling and that they do not affect testing at all.

I'm now completely confused as to which person is correct. Could someone please clarify which technique is best for an object to persist for the lifetime of the app, and be accessible to other classes, and also maintain loose coupling. To me, the object passing by method or property to each class seems the most logical, but I do not know!

Thanks in advance for any help!

答:
Regarding the Singleton, consider a case where you want to test a class that uses a Singleton, but you wish to mock it. You can do it by extracting a method called getSingleton and then overriding it in a testable subclass, but it gets messy this way.

Your class will be more testable if it accepts the dependency on the other class in the constructor. You can then inject a mock dependency in your tests.

If you apply this throughout your project, you will discover you don't need any Singletons anymore, but you do need to "wire" your project up basically from the main method.

Guice is a DI framework that helps with this, but I recommend playing with it manually first, so you learn the concepts.

If you want to learn more, I really recommend what Miško Hevery has to say.

Videos:

http://googletesting.blogspot.com/2008/11/clean-code-talks-dependency-injection.html

http://googletesting.blogspot.com/2008/11/clean-code-talks-global-state-and.html

http://googletesting.blogspot.com/2008/12/by-miko-hevery-google-tech-talks.html

Blogs:

http://misko.hevery.com/2008/09/10/where-have-all-the-new-operators-gone/

http://misko.hevery.com/2008/07/08/how-to-think-about-the-new-operator/

http://misko.hevery.com/2008/09/10/where-have-all-the-new-operators-gone/


问:
How to specify a functional requirement?
I have this requirement:

```<code>The application must allow the Administrator to edit, create and delete Users.
</code>```

Now, I have heard that each action must go in a functional requirement, and my question is: What of the following statements would be the more appropriate(if any):

1:

```<code>The application must allow the Administrator to edit, create and delete Users.
</code>```

2:

```<code>The application must allow the Administrator to edit Users.
The application must allow the Administrator to create Users.
The application must allow the Administrator to delete Users.
</code>```

答:
I would go for number two.

Functions in function definitions while they should be worded in business terms should be atomic. What I mean by that is "maintain customer data" could include add, edit, delete, archive, disable etc. etc. A in list of functions "delete the customer data" could mean only one thing.

This helps specify the system more exactly in discussion with users as they are liable to say things like "I didn't mean remove the customer form the file, I meant flag him as an ex-customer", which they might have felt was an obvious implication of "maintain customer data".


问:
What is .NET framework backward compatibility?
We develop a windows application in .NET 4 with a database of MySQL. When we are about to deploy that application, we install the .NET 4 framework in our client, then when installing the .NET Connector for MySQL, it requires a .NET framework 3.5. But the .NET 4 is already installed. Wasn't .NET framework backward compatible?

We end up installing two .NET framework (3.5 & 4) which isn't small in disk size. What exactly does backward compatibility means?

答:
To quote MSDN:

The .NET Framework 4 is backward-compatible with applications that
  were built with the .NET Framework versions 1.1, 2.0, 3.0, and 3.5. In
  other words, applications and components built with previous versions
  of the .NET Framework will work on the .NET Framework 4.

However, in practice, this compatibility can be broken by seemingly
  inconsequential changes in the .NET Framework and changes in
  programming techniques. For example, performance improvements in the
  .NET Framework 4 can expose a race condition that did not occur on
  earlier versions. Similarly, using a hard-coded path to .NET Framework
  assemblies, performing an equality comparison with a particular
  version of the .NET Framework, and getting the value of a private
  field by using reflection are not backward-compatible practices. In
  addition, each version of the .NET Framework includes bug fixes and
  security-related changes that can affect the compatibility of some
  applications and components.

You should test your .NET Framework applications and components to
  ensure that they are compatible with other versions of the .NET
  Framework. To ensure that an application or component successfully
  runs on the .NET Framework 4, use the .NET Framework 4 Application
  Compatibility Walkthrough.

You may also see this very useful thread wherein a detailed explanation was given:

https://stackoverflow.com/questions/2816914/backwards-compatibility-of-net-framework-4


答:
Well, let's start with singletons.

I'm a JS/client-side web dev who has just recently decided to implement singletons. I'm writing UI objects that are somewhat monolithic in that they represent all UI elements of a given type on a page. The UI object is factory, warehouse, and event/interface manager.

The point in building and managing all instances of these UI elements of a given type from the same type-representing object is that sometimes in UI I want to deal with one UI element at a time and sometimes I want all of them to respond to the same event. Also, it makes it easier to create a more event-driven interface, which is something I've been geeking out on as of late.

But if I were to allow multiple factories from the same constructor, I'd have a nasty or at least clumsy time of trying to to hit all the UI elements with a global event, for instance, because each general UI type object instance would only have the references to UI elements that it actually built. Instead, my general UI type object factory methods will simply return a reference to the original objects when they've already been created. One Class/Constructor. One Instance.

The short version:

Singletons are about preventing multiple instantiations when having multiple instantiations might cause a problem. The end.

Now moving away from Singletons, the subject of tight-coupling:

Tight coupling is typically about excess dependencies. One big fat global object that's containing way too much state information without any means of verifying where that info came from might be problematic, but it's not tight-coupling. When things are too-tightly-coupled, I touch one function or object or random element of the environment (like say an HTML class on the web) and boom everything breaks.

Passing a reference to the same object around excessively and in weird/random ways could result in a tightly coupled-scenario, but mostly it's a good idea when you know your refs from your vars/properties that are getting passed by value and capitalizing on that knowledge wisely.

Title: Design patterns: moving object references around an application

Body:
I'm new to Programmers and I am looking to increase my knowledge of programming. Recently, a user on Stack Overflow told me using singletons is a bad idea, that they encourage tight coupling and that they make testing harder.

What prompted this discussion was that every class I've ever written accessed any kind of data through a singleton. For example, a class that handles state data for a game. If any other class wanted to access this data, all they would have to do is get the singletons instance and there it would be. Specifically, instantiating a class on the AppDelegate, then accessing it via: [[[[UIApplication sharedApplication] delegate] gameObject] getScore].

The SO user told me that I should instantiate the 'gameObject' wherever I first need it, then pass that object to every other class that needs it via either a method as an argument, or via a property.

I was discussing these points when someone else pointed out that this information is completely wrong, that singletons are unrelated to coupling and that they do not affect testing at all.

I'm now completely confused as to which person is correct. Could someone please clarify which technique is best for an object to persist for the lifetime of the app, and be accessible to other classes, and also maintain loose coupling. To me, the object passing by method or property to each class seems the most logical, but I do not know!

Thanks in advance for any help!


答:
Your answer is the second option. Creating, editing and deleting are different actions, so you  must have each of them explicitly stated.

Consider that a new user type comes into play, Moderator. A new requirement arises, Moderators can create users but cannot edit or delete. Now if you wrote your first requirement specification as:

The application must allow the Administrator to edit, create and delete Users.

and your second requirement as:

Moderators can create users.

it looks like they are seperate functionalities. But in your second option you can easily observe that Administrator and Moderator shares a common functionality "Creating" users.

Title: How to specify a functional requirement?

Body:
I have this requirement:

```<code>The application must allow the Administrator to edit, create and delete Users.
</code>```

Now, I have heard that each action must go in a functional requirement, and my question is: What of the following statements would be the more appropriate(if any):

1:

```<code>The application must allow the Administrator to edit, create and delete Users.
</code>```

2:

```<code>The application must allow the Administrator to edit Users.
The application must allow the Administrator to create Users.
The application must allow the Administrator to delete Users.
</code>```


问:
Getting users to write decent and useful bug reports
Does anyone know a good way to get users to write a semi-decent (read: useful) bug report?

We wanted to put up something that would make sense to most users (be easy to read and understand), yet give useful information to developers as well.

It does not work when I click the blue button! Ahhh, I just lost a week's work ... make it work.

isn't very useful, as it is.

I started to fix about a list, but thought to check up with you guys, whether a similar method already exists.

答:
You can ask easy to understand and easy to answer questions to users to expect useful reports.

For example, "What was your last action before this error?", "Did you try to ... just before this error?".

No user would write you a bug report like : "My video driver is not uptodate. Your graphics library might not be compatible with old graphic drivers."

OwnerDisplayName: ldigas


答:
The most effective way to get users to write decent and useful bug reports is

to let them see their reports online...

 [System] Thanks for reporting, you can find status of your request here: ...

...along with the evaluation and comments from assigned engineer...

 [Engineer] Request rejected, for the following details are missing: ...

...with an option to edit / improve their report.

 [User] Requested details are added, please re-evaluate: ...

I would go as far as to claim that it's the only effective way.

Let's face it, skill to write bug reports effectively  comes only with experience. One needs to learn to gain experience. Learning involves practicing, getting feedback and improving.

User-editable online bug reports are the most efficient way to teach users improve.

Alternative options to above are 1) to arrange face-to-face learning sessions with users (yeah sure, especially when there are thousands of them spread across the globe). Or 2) explain them things by the phone ("look, if you could only see the crap you wrote at line 225..."). What else? Oh 3) by email, sure "in the mail you sent us two months ago, you mentioned... no not that email, you sent us five emails this day, three of them were with subject Re: blue button click, look at the second one, the one with 10Mb screen shot attached to it... what? you can't find it?"

Title: Getting users to write decent and useful bug reports

Body:
Does anyone know a good way to get users to write a semi-decent (read: useful) bug report?

We wanted to put up something that would make sense to most users (be easy to read and understand), yet give useful information to developers as well.

It does not work when I click the blue button! Ahhh, I just lost a week's work ... make it work.

isn't very useful, as it is.

I started to fix about a list, but thought to check up with you guys, whether a similar method already exists.


答:
First is better.

It's more concise and equally clear.

A functional requirement is a way of communicating to others what the software needs to do. If you are treating it like a checklist or a legal document where everything must be laid out in laborious detail, then you are doing it wrong IMHO.

Even better would be to leave the requirement at a higher level:

Administrators must be able to manage the list of users

It is then up to the team to determine the best way to implement this. This might involve editing, creating and deleting users. But it might equally include bulk upload or some other features that you didn't think about in your initial functional requirements and might need to be developed over a couple of iterations with real users.


答:
Singletons are very much like global variables with a namespace. Almost all people tell you global variables are bad, but somehow, Singletons are ok.

Having said that, Singletons have some specific uses. It can be used when you definitely want one instance of something. For example - you want only 10 Database Threads, otherwise your database server will crash under load. Your ThreadPool class then should be a Singleton, and manage the DB threadpool.

Another use may be if you have read-only ( or rarely changing ) configs which are essentially global variables. In this case it would save memory and occasional file IO to have it as a Singleton.

In your example - you want to have a GameState as a Singleton. Why would you limit your program to one game? Even if you wanted one game initially, you are restricting yourself by putting singleton logic in the GameState class.

I'm not sure of your application - but I would have created a Game Object separately :

```<code>void startGame() {
    Game gs = new Game();
    gs.play();
}
</code>```

Now how do we find the score? Depends on who needs the score. If I assume the Game class owns the score, then it can have a getScore() function. Sometimes a Player may need a score. This can be solved by letting the Players have a Game reference.

```<code>void startGame(Player[] players) {
    Game gs = new Game();
    for ( Player player : players ) {
        player.registerForGame(this);
    }
    gs.addPlayers(players);
    gs.play();
}
Player::registerForGame(Game game) {
    this.currentGame = game;
}
</code>```

The code is not in any particular language - just an illustration of how it could be designed without singletons. Also, I don't claim this to be a "good" design - for example the Game class will probably to too much here, if the Game has lots of functionality.

As someone mentioned design is just a lot of tradeoffs and you have to do what makes sense for a particular problem.

Body:
Singletons are very much like global variables with a namespace. Almost all people tell you global variables are bad, but somehow, Singletons are ok.

Having said that, Singletons have some specific uses. It can be used when you definitely want one instance of something. For example - you want only 10 Database Threads, otherwise your database server will crash under load. Your ThreadPool class then should be a Singleton, and manage the DB threadpool.

Another use may be if you have read-only ( or rarely changing ) configs which are essentially global variables. In this case it would save memory and occasional file IO to have it as a Singleton.

In your example - you want to have a GameState as a Singleton. Why would you limit your program to one game? Even if you wanted one game initially, you are restricting yourself by putting singleton logic in the GameState class.

I'm not sure of your application - but I would have created a Game Object separately :

void startGame() {
    Game gs = new Game();
    gs.play();
}

Now how do we find the score? Depends on who needs the score. If I assume the Game class owns the score, then it can have a getScore() function. Sometimes a Player may need a score. This can be solved by letting the Players have a Game reference.

void startGame(Player[] players) {
    Game gs = new Game();
    for ( Player player : players ) {
        player.registerForGame(this);
    }
    gs.addPlayers(players);
    gs.play();
}
Player::registerForGame(Game game) {
    this.currentGame = game;
}

The code is not in any particular language - just an illustration of how it could be designed without singletons. Also, I don't claim this to be a "good" design - for example the Game class will probably to too much here, if the Game has lots of functionality.

As someone mentioned design is just a lot of tradeoffs and you have to do what makes sense for a particular problem.


问:
What popular "best practices" are not always best, and why?
"Best practices" are everywhere in our industry.  A Google search on "coding best practices" turns up nearly 1.5 million results.  The idea seems to bring comfort to many; just follow the instructions, and everything will turn out fine.

When I read about a best practice - for example, I just read through several in Clean Code recently - I get nervous.  Does this mean that I should always use this practice?  Are there conditions attached?  Are there situations where it might not be a good practice?  How can I know for sure until I've learned more about the problem?

Several of the practices mentioned in Clean Code did not sit right with me, but I'm honestly not sure if that's because they're potentially bad, or if that's just my personal bias talking.  I do know that many prominent people in the tech industry seem to think that there are no best practices, so at least my nagging doubts place me in good company.

The number of best practices I've read about are simply too numerous to list here or ask individual questions about, so I would like to phrase this as a general question:

Which coding practices that are popularly labeled as "best practices" can be sub-optimal or even harmful under certain circumstances?  What are those circumstances and why do they make the practice a poor one?

I would prefer to hear about specific examples and experiences.

答:
Always program to interfaces.

Sometimes there will only be one implementation.  If we delay the process of extracting an interface until the time when we see the need for it, we will often find it isn't necessary.

ContentLicense: CC BY-SA 2.5


答:
Assuming the user base is end users who have had a problem with the software you wrote....

It's not your users job to become a proficient Software Engineer or Testing professional, and you should not expect them to. Your users are average people who rightly expect the  the software to "just work".  When it doesn't, they will report whatever they think they heed to to get your attention. You cannot change that, and should not attempt to. Any attempt to insist on the kind of reports a professional is expected to make will result in the loss of the bug report, and the customer - "I had a problem with that software, but instead of helping me, they made be fill in all sorts of useless forms that mean nothing and have no value to me. I'll go find some software that actually works.".

i.e. It's not their job.....

If you want good bug reports, employ professionals to find your bugs. If you, as a software developer, can't be bothered dealing with customers, employ someone who can.


答:
It would definitely be 2. But it should contain more.

In general, write the minimum line you can think of - and then break it.

For example

Administrator should be able to add a User.

Looks good? You have to gather much more requirements.

Define what a "User" is, i.e. the attributes of user ( name, address,
picture, etc.. ).

Define which ones are mandatory ( name?, tel-no? ) and required while adding

Then ask more questions

Do I need First, Last and Middle. Are all of them necessary?

Do I need Area code for Tel-no? International code? which ones are mandatory?

You can keep asking questions about the application and come up with more granular specifications. Don't assume anything.

You get the general idea.


问:
How do I determine if my code is optimized?
I am only developer working on a project. The functionality that I have coded works to expectations(desired result) but since I am the only one I don't know if I can do anything better to it. How do I determine if my code is optimized (I want to increase the performance of some features)?

One thing that comes into mind is Code Review but there is no one free over here to review my code. I just keep on trying with alternate logic but at times things get stagnant and really dirty. Is there any other possible way?

答:
Profile your app and look in which functions your code spends the most time, then go about optimising those specific functions. You could spend days optimising one function only to discover that it's only called a couple of times, whereas there are little functions that get called hundreds of times, these are the ones to look at.

Replacing objects with low-level data types sometimes helps, also make sure that in conditionals the most likely conditions are evaluated first.

Also try playing with build settings, like compiler optimisation levels, stripping debug symbols and so on.


答:
Looking at http://dev.mysql.com/doc/refman/5.6/en/connector-net-versions.html, I guess you don't need version 3.5, version 2.0 should be enough (which is much smaller and part of 3.5).

If nothing else helps, you could try to compile the connector by yourself against FW 4.0, see http://dev.mysql.com/doc/refman/5.6/en/connector-net-installation-source.html

Title: What is .NET framework backward compatibility?

Body:
We develop a windows application in .NET 4 with a database of MySQL. When we are about to deploy that application, we install the .NET 4 framework in our client, then when installing the .NET Connector for MySQL, it requires a .NET framework 3.5. But the .NET 4 is already installed. Wasn't .NET framework backward compatible?

We end up installing two .NET framework (3.5 & 4) which isn't small in disk size. What exactly does backward compatibility means?


问:
What is the benefit of hypermedia (HATEOAS)?
I don't understand the benefit to HATEOAS for APIs intended for use by programs (as opposed to humans directly browsing your API).  Sure, the customer isn't bound to a URL schema but they are bound to a data schema which is the same thing in my mind.

For example, assume I want to view an item on an order, let's assume I've discovered or know the order URL already.

HATEOAS:

```<code>order = get(orderURL);
item = get(order.itemURL[5]);
</code>```

non-HATEOAS:

```<code>order = get(orderURL);
item = get(getItemURL(order,5));
</code>```

In the first model I have to know the fact that the order object has an itemURL field.  In the second model I have to know how to construct an item URL.  In both cases I have to "know" something ahead of time so what is HATEOAS actually doing for me?

答:
One difference is that the schema is hopefully a standard, or at least can be reused by others.

For example, let's say you're using the Twitter API and you want to support StatusNet too (or instead). Since they use the same data model as Twitter, if the API follows HATEOAS you now just have to change the main URL. If it doesn't, you now have to change each single URL from the code.

Of course, if you need to change the code to put the service's entry point URL anyway, it might not seem so helpful. It really shines is if that URL is dynamically inserted; for example, if you were building a service like Twillio, which would interact with the user's own API.


问:
Whiteboard "testing" during an interview: legitimate way to back up your (whiteboard) code?
As I get it, having an error (even a typo like or missing ";") in your whiteboard code will often cost you some interview points. Avoiding that will inevitably make one proof-reading code again and again (losing time and possibly neural energy / concentration) or even using a simpler (and thus less effective) algorithm -- and both these ways are "costly" again!

So, why not just fast write code as elegant and effective as you would having a (unit) testing framework at your disposal and then just normally test it it (just on the whiteboard)?

Has anyone tried / seen this approach? Is the whole idea worthy?

[this also applies to the pen-and-paper case of course]

答:
White board coding is tough. I was never introduced to that until I was interviewed by Disney. Not knowing what to expect and not being able to debug it, I stumbled through it talking it through and solving the problem, but in a pseudo code kinda of way. When they asked could it run.

I mean sure it could you just have to fix the syntax errors, correct. I believe they lost a very good candidate if I was not hired because of the whiteboard. I look at the qualifications and it looks like I am way qualified for the position and can do the job. I excel at the current job I am at and wished I could with them.

Thanks for your input Kate, I read every word. It's just to me as a programmer, white board really doesn't show your skills. I'm a great programmer that work in multiple languages. I knew the language I was asked to program in, but on white board I suddenly forgot.

I build complex integration and credit card processing, but on white board I couldn't remember how to even do proper syntax nothing prompt me.

As an employer I do like the white board testing; however, I am hiring a programmer I want to see their actual skills if they do the job. It's great if they can communicate, but I need to see them be able to solve problems.


答:
Ask youself:

What do you want to optimize for?

Do I really need to optimize for this particular thing, or is it actually good enough?

As far as "what for" goes, a few possible answers and what you should do:

maintainability - the best test here is real-world production usage, but using that alone yields some kind of a vicious circle. However, you can have someone else review your code; you can check if others can work with it well; you can run over a checklist of what you consider code smells, or, more positively, a checklist of what you consider must-haves for well-written code. Document everything, and have someone else read the documentation and tell you which parts are unclear.

correctness and reliability - write automated tests that cover everything that can be meaningfully tested, and design your code to be as testable as possible. Put on your destruction monkey hat and see if you can use your own code in a way that breaks it; then go fix it. Write a detailed test plan that covers all the functional and technical requirements, including 'negative' cases (i.e., describe what you expect the code to do when you use it in unintended ways); let someone else execute the test plan and consider all negative responses bugs in either the design, the code, or the test plan.

run-time performance - there is no replacement for profiling here. Before attempting to optimize anything for performance, first make sure it is correct; then make sure the part you are going to optimize is indeed a problem area. Then change one thing, and measure the performance before and after. Don't forget to test against realistic data, including huge datasets - many algorithms work fine (even faster) for small datasets, but come to a grinding halt when the dataset exceeds a certain size. Optimize algorithms before code - algorithms can make an exponential difference, while optimizing code practically never wins you any gain beyond linear. Also, go for the easy fixes first: compiler optimization settings (these are basically free), simple refactorings (pass-by-const-reference instead of pass-by-value and such), caching (can be done at several levels, you'll have to judge where it makes the most sense), and whatever can be implemented easily in the code you already have. Note that there are several orthogonal measurement for "performance", such as CPU load, latency, memory footprint, etc.; quite often, you have to balance one of those against another, e.g. reducing CPU usage at the cost of an increased memory footprint. See Mark Booth's comment for more details. And don't forget, sometimes (though not often) "throw more hardware at it" is the correct answer.

profitability - analyze which features make you the most money, and what parts of the application are possible stumbling blocks for generating more revenue. For web applications, tracking usage patterns is probably the most promising way to do this. Then estimate how much you would have to spend on each part to fix it, and by how much it would increase your revenue. From there, it should be clear which issues you should take up first.

Title: How do I determine if my code is optimized?

Body:
I am only developer working on a project. The functionality that I have coded works to expectations(desired result) but since I am the only one I don't know if I can do anything better to it. How do I determine if my code is optimized (I want to increase the performance of some features)?

One thing that comes into mind is Code Review but there is no one free over here to review my code. I just keep on trying with alternate logic but at times things get stagnant and really dirty. Is there any other possible way?


问:
What are some of the major differences in process management between CGI and newer (better) technologies?
I know CGI spawns a new process for every HTTP request that it serves, while servlets use one Java process to serve many requests. What do other technologies (rails, WSGI/django, mod_php, asp.net etc.) do so that web servers do not have to spawn a new process new HTTP request?</p>

答:
In general, what happens is that servers pool threads to support multiple connections. Once the connection is released, the thread is returned to the pool to be used by the next connection. Now the details of this is different for most things. Thinking about what happens to make this work well, systems will open up a process and reuse it to handle multiple requests once it's returned to the pool.

App Servers bundled inside the web server (ASP.NET, Tomcat) don't have to worry about executing external processes because they built on the assumption that your code will handle threading correctly. When talking about Ruby on Rails for instance, most things are not thread safe. Reuse within in the same process would likely lead to undesirable results. (For rails, at least on JRuby, this likely less of the problem it once was.)


问:
Are functional languages better at recursion?
TL;DR : Do functional languages handle recursion better than non-functional ones?

I am currently reading Code Complete 2. At some point in the book, the author warns us about recursion. He says it should be avoided when possible and that functions using recursion are generally less effective than a solution using loops. As an example, the author wrote a Java function using recursion to compute the factorial of a number like so (it may not be exactly the same since I do not have the book with me at the moment):

```<code>public int factorial(int x) {
    if (x <= 0)
        return 1;
    else
        return x * factorial(x - 1);
}
</code>```

This is presented as a bad solution. However, in functional languages, using recursion is often the preferred way of doing things. For example, here is the factorial function in Haskell using recursion:

```<code>factorial :: Integer -> Integer
factorial 0 = 1
factorial n = n * factorial (n - 1)
</code>```

And is widely accepted as a good solution. As I have seen, Haskell uses recursion very often, and I did not see anywhere that it is frowned upon.

So my question basically is:

Do functional languages handle recursion better than non-functional ones?

EDIT : I am aware that the examples I used are not the best to illustrate my question. I just wanted to point out that Haskell (and functional languages in general) uses recursion much more often than non-functional languages.

答:
The only technical reason I know of is that some functional languages (and some imperative languages if I recall) have what's called tail call optimization which allow a recursive method to not increase the size of the stack with every recursive call (ie. the recursive call more-or-less replaces the current call on the stack).

Note, that this optimization doesn't work on any recursive call, only tail-call recursive methods (ie. methods that don't maintain state at the time of the recursive call)


问:
What's the difference between Entry Level/Jr/Sr developers?
Other than title and pay, what is the difference?

What different responsibilities do they have.

How knowledgeable/experienced are they?

What is the basic measure to determine where a developer fits into this basic structure?

答: This strictly depends on the company.  But the words are fairly obvious: entry level is someone who is just entering the field, junior is someone who is beyond entry level and knows there way around a few languages technologies.  Lastly senior are those who are more in charge of the project and sit at a higher level.  They can usually delegate as much as they code. </p>


答:
TL;DR: Yes they do

Recursion is a key tool in functional programming and therefore a lot of work has been done on optimizing these calls. For example, R5RS requires (in the spec!) that all implementations handle unbound tail recursion calls without the programmer worrying about stack overflow. For comparison, by default the C compiler won't do even an obvious tail-call optimization (try a recursive reverse of a linked list) and after some calls, the program will terminate (The compiler will optimize, though, if you use -O2).

Of course, in programs that are horribly written, such as the famous fib example which is exponential, the compiler has little to no options to do its 'magic'. So care should be taken not to hinder the compiler efforts in optimization.

EDIT: By the fib example, I mean the following:

```<code>(define (fib n)
 (if (< n 3) 1
  (+ (fib (- n 1)) (fib (- n 2)))
 )
)
</code>```

Title: Are functional languages better at recursion?

Body:
TL;DR : Do functional languages handle recursion better than non-functional ones?

I am currently reading Code Complete 2. At some point in the book, the author warns us about recursion. He says it should be avoided when possible and that functions using recursion are generally less effective than a solution using loops. As an example, the author wrote a Java function using recursion to compute the factorial of a number like so (it may not be exactly the same since I do not have the book with me at the moment):

```<code>public int factorial(int x) {
    if (x <= 0)
        return 1;
    else
        return x * factorial(x - 1);
}
</code>```

This is presented as a bad solution. However, in functional languages, using recursion is often the preferred way of doing things. For example, here is the factorial function in Haskell using recursion:

```<code>factorial :: Integer -> Integer
factorial 0 = 1
factorial n = n * factorial (n - 1)
</code>```

And is widely accepted as a good solution. As I have seen, Haskell uses recursion very often, and I did not see anywhere that it is frowned upon.

So my question basically is:

Do functional languages handle recursion better than non-functional ones?

EDIT : I am aware that the examples I used are not the best to illustrate my question. I just wanted to point out that Haskell (and functional languages in general) uses recursion much more often than non-functional languages.

Body:
TL;DR: Yes they do

Recursion is a key tool in functional programming and therefore a lot of work has been done on optimizing these calls. For example, R5RS requires (in the spec!) that all implementations handle unbound tail recursion calls without the programmer worrying about stack overflow. For comparison, by default the C compiler won't do even an obvious tail-call optimization (try a recursive reverse of a linked list) and after some calls, the program will terminate (The compiler will optimize, though, if you use -O2).

Of course, in programs that are horribly written, such as the famous fib example which is exponential, the compiler has little to no options to do its 'magic'. So care should be taken not to hinder the compiler efforts in optimization.

EDIT: By the fib example, I mean the following:

(define (fib n)
 (if (< n 3) 1
  (+ (fib (- n 1)) (fib (- n 2)))
 )
)


答:
Haskell and other functional languages generally uses lazy evaluation. This feature lets you write non-ending recursive functions.

If you write a recursive function without defining a base case where recursion ends, you end up with having infinite calls to that function and stackoverflow.

Haskell also supports recursive function call optimizations. In Java each function call would stack up and cause overhead.

So yes, functional languages handle recursion better than others.


答:
You're comparing recursion vs iteration. Without tail-call elimination, iteration is indeed more efficient because there's no extra function call. Also, iteration can go on forever, whereas it is possible to run out of stack space from too many function calls.

However, iteration requires changing a counter. That means there must be a mutable variable, which is prohibited in a purely functional setting. So functional languages are specially designed to operate without the need for iteration, hence the streamlined function calls.

But none of that addresses why your code sample is so sleek. Your example demonstrates a different property, which is pattern matching. That's why the Haskell sample doesn't have explicit conditionals. In other words, it's not the streamlined recursion that makes your code small; it's the pattern matching.


答:
Technically no, but practically yes.

Recursion is far more common when you're taking a functional approach to the problem. As such, languages designed to use a functional approach often include features that make recursion easier/better/less problematic. Off the top of my head, there are three common ones:

Tail Call Optimization. As pointed out by other posters, functional languages often require TCO.

Lazy Evaluation. Haskell (and a few other languages) is lazily evaluated. This delays the actual 'work' of a method until it is required. This tends to lead to more recursive data structures and by extension, recursive methods to work on them.

Immutability. The majority of stuff you work with in functional programming languages is immutable. This makes recursion easier because you don't have to concern yourself with the state of objects over time. You can't have a value changed out from underneath you for example. Also, many languages are designed to detect pure functions. Since pure functions have no side effects, the compiler has a lot more freedom about what order the functions run in and other optimizations.

None of these things are really specific to functional languages versus others, so they're not simply better because they're functional. But because they're functional, the design decisions made will tend towards these features because they're more useful (and their downsides less problematic) when programming functionally.


问:
Are there any scientific studies done on TDD that use total cost of ownership for a product as the measurement?
When I was reading the summary of previous work in Dogsa T, Batic D. The effectiveness of test-driven development: an industrial case study. Software Quality Journal. 2011;19(4):643-661. it struck me that the measurements used in a lot of studies around TDD are based on things like lines of code, defects and time spent on development.

Are there any studies out there that focus on the total cost of ownership for products that have been developed using TDD vs ex traditional development or test-last?

I am especially interested in the total cost of acquisition and operating costs.

答:
There are some studies about the implications and benefits of doing TDD, but the results are contradictory. Some projects (this is in my experience) have a lower bug rate and cost to ownership as a result of using TDD, as the cost of changing a feature reduces drastically. Some others are halted to a stop.

Some studies (here is one - check slide n50) show that the number of bugs increased with the coverage. I'm assuming that greater coverage implies TDD and that a higher number of bugs implies a higher cost of ownership.

From my point of view, no metric or practice on its own can be related to better quality or lower cost of ownership. There's a combination of factors that can lead to some correlation. And those factors change between teams and projects.

I think we've all heard stories of teams, which just started doing TDD, writing 100-line test methods, which (in my view) increases the cost of ownership, as updating that test will be expensive.

My pragmatic rule is that people who care and are eager to learn, working in an environment that supports them and their ideas have better quality and cost of ownership.


答:
```<code>code.optimized = users.happyWithPerformance ? true : false;
</code>```


答:
I don't have any specific studies but I can tell you from personal experience, and from the experiences of other developers I know that when applied correctly for medium and larger projects TDD reduces time to market, reduces bugs and defects, and improves code quality.

Having said that their are no silver bullets, can you write good code with out TDD? yes, can you write bad code using TDD yes.  Also depending on your project TDD can greatly increase your cost of ownership for the code, a good example is NASA, where the cost per line of code is huge, but the cost of ownership isn't the focus, it's lack of defects.

When applied correctly TDD will increase your starting costs, and your code base, but you get the long term benefits of regression testing, early bug detection, and better code design which should reduce defects and testing costs and maintenance time, thus reducing overall cost of ownership.

Title: Are there any scientific studies done on TDD that use total cost of ownership for a product as the measurement?

Body:
When I was reading the summary of previous work in Dogsa T, Batic D. The effectiveness of test-driven development: an industrial case study. Software Quality Journal. 2011;19(4):643-661. it struck me that the measurements used in a lot of studies around TDD are based on things like lines of code, defects and time spent on development.

Are there any studies out there that focus on the total cost of ownership for products that have been developed using TDD vs ex traditional development or test-last?

I am especially interested in the total cost of acquisition and operating costs.


问:
Why is the output of a compiler called object code?
From the essay Programming Languages Explained by Paul Graham, published in Hackers & Painters:

The high-level language that you feed the compiler is also known as
  source code, and the machine language translation it generates is called object code.

From the Wikipedia article on object code:

Object code, or sometimes object module, is what a computer compiler
  produces.

From a definition of 'compiler':

Traditionally, the output of the compilation has been called object
  code or sometimes an object module. (Note that the term "object" here
  is not related to object-oriented programming.)

So what is the term object related to?

答:
Object code is produced when you compile a source code. This object code is not executable yet because it does not have required libraries to run. So you link multiple object codes and libraries and it becomes an executable.

In my understanding "object" relates to the "thing" you developed by writing that source code. It can be a module, class, function or anything.


问:
Developing the Domain Model alone
In DDD examples it seems the common method for developing the domain model is to sit with domain experts and iterate over versions of the model, say on a whiteboard, continually modifying it and changing it until presumably an agreement is made on how the model looks.

On my project I've spent a couple of days with a domain expert, discussing the domain, and now I want to lock myself away and produce a draft model based on my understanding, rather than producing the model collaboratively with the domain expert. He could then review it, and I could update it according to our subsequent discussions.

Has anyone else worked like this, or does anyone think its a good / bad idea? I think maybe I just find it easier to think creatively when alone.

答:
The only thing that bothers me about your explanation is "lock my self".

Ofcouse you should be developing what you understand from discussion alone (without Domain Expert) but communication should be always open. The sooner you decide to change things the better.

Always communicate and try to understand each other. However as a developer, you will understand the domain better than he understands the model that you are developing, so I think you should be the one deciding how to design the model.

Title: Developing the Domain Model alone


答:
Object code is sometimes also called target code, because it is the target result of the translation process performed by compilers. So "object code" is used as an opposite of "source code".

There are other strange names in the compiler world: for example, the segment of the file with the binary code of your program is often called "the text segment".

Title: Why is the output of a compiler called object code?

Body:
From the essay Programming Languages Explained by Paul Graham, published in Hackers & Painters:

The high-level language that you feed the compiler is also known as
  source code, and the machine language translation it generates is called object code.

From the Wikipedia article on object code:

Object code, or sometimes object module, is what a computer compiler
  produces.

From a definition of 'compiler':

Traditionally, the output of the compilation has been called object
  code or sometimes an object module. (Note that the term "object" here
  is not related to object-oriented programming.)

So what is the term object related to?


答:
If the code actually conforms to the implicit and explicit expectations then you might not need to optimize it at all.  Your time might be better spent elsewhere adding more functionality.

The way you phrase your question makes me think that you feel there are some implicit expectations that you have not fully achieved with your code though.  Maybe  you should check with your client first to see what they actually expect.

Be careful that you are not stepping into the trap of gold-plating.

If you are still confident of wanting to optimize after the above, then follow tdammer's advice.


答:
It is object as in "objective".  Not object as a "thing".

Similar to dasblinkenlight's answer about being called "target code".  It is the target or objective of the compiler.


答:
Yes, they do, but not only because they can, but because they have to.

The key concept here is purity: a pure function is a function with no side effects and no state. Functional programming languages generally embrace purity for many reasons, such as reasoning about code and avoiding non-obvious dependencies. Some languages, most notably Haskell, even go so far as to allow only pure code; any side effects a program may have (such as performing I/O) are moved to a non-pure runtime, keeping the language itself pure.

Not having side effects means you can't have loop counters (because a loop counter would constitute mutable state, and modifying such state would be a side effect), so the most iterative a pure functional language can get is to iterate over a list (this operation is typically called foreach or map). Recursion, however, is a natural match with pure functional programming - no state is needed to recurse, except for the (read-only) function arguments and a (write-only) return value.

However, not having side effects also means that recursion can be implemented more efficiently, and the compiler can optimize it more aggressively. I haven't studied any such compiler in depth myself, but as far as I can tell, most functional programming languages' compilers perform tail call optimization, and some may even compile certain kinds of recursive constructs into loops behind the scenes.


答:
It's going to boil down to the company's expectations of the programmer.

If I'm the hiring company and I hire an Entry Level programmer, I know that that person knows next to nothing and we're going to assume he/she needs to learn everything.  If I hire a Senior level person, in theory, they'll be self sufficient, from a technical stand point.

Title: What's the difference between Entry Level/Jr/Sr developers?

Body:
Other than title and pay, what is the difference?

What different responsibilities do they have.

How knowledgeable/experienced are they?

What is the basic measure to determine where a developer fits into this basic structure?


答:
I'd say you need to look for

Is it fast enough?  I wouldn't spend too much time bringing page load time from 1 second down to 0.1sec for a site that will see 50 visitors a day.

Open your solution, and try to look at your code like if you've never seen it before. Does it make sense ? Can you read it, and understand what it does and why it does it like that ?  Maintainability is the key (unless it's one-off piece that you will never run again).

If you want a somewhat a better quantified measure, VS (if you're using .NET) has a code analysis tool, which will give you a rough idea of your code maintainability/complexity.


问:
Making an internship most effective, useful and fun for both parties
We're currently interviewing few candidates for an internship, which is a really new experience for us as a company and for me personally as a team lead/manager. </p>

<p>What would be the most effective and useful, yet fun approach for both sides here? How do we 'integrate' an intern into our development team and workflow without much disruption in such a way that he or she could be learning and yet be helpful? </p>

答:
You have to be conscious of the stage of learning your intern fits in and what motivates him. The first point will help your intern develop as a professional, the second will help you develop as a manager/leader.

I suggest reading on Pragmatic Thinking and Learning to understand the stages of learning.

Basically it says that there are stages of learning and work has to progress through them. The very first stages people need clear recipes with well defined contexts, they work by example. Then they learn to solve new problems, and later on they learn to optimize their work. So you want to find out where he stands and provide him work accordingly, else he won't learn.

So it's not wrong to give your intern monkey work, if you feel he's in that stage, if he needs to learn to read code, learn to speak your DSLs, to interact with your services/databases, etc. If the challenge is beyond his level he will fail, and some people have yet to overcome failure as a demotivator.

On motivation there is some good thoughts in Management 3.0.

The idea is that every person has different motivators on different levels. People seek challenge, money, status, freedom, power, gratitude, fitting in, standing out, etc all on different levels. It's up to you to understand what drives them and find a way to provide that.

I tend to think of it like an exchange currency specific to each person. If the person misses theirs, they start questioning if the company provides them with a fair deal. If my currency is status, but they only provide me money, I have to exchange money for status somehow in my life to feel satisfied, and I often lose in the exchange taxes.

On what has been said about the kind of work interns do, I will stand against the "real work" crowd.

Computer Science Bachelors often get bored doing "real work" on the enterprise segment. That's another thing you have to go by feeling. Some people like being academics, so you better turn them into a mini-R&D, get them to build tools, metrics, etc. Make them feel the scientists inside the corporation, don't let them crawl back to academia frustrated with the enterprise.

Other people are just looking for a chance to get out of the fantasy world of academia and are eager to learn the business.


问:
Should the most recent date be named 'start' or 'end'?
So I have a function that takes two dates.  The SQL query gets all the results between the two dates.  I currently have my function setup as such:

```<code>function myFunc(start, end)
</code>```

Where start is the most recent date and end is the oldest date.

Is this intuitive/correct or is there another naming/ordering convention I should be using?

答: Typically, you'd think that start <= end, so not really. Consider renaming it to give a hint to the business logic you are trying to implement.</p>


答:
Why not just name them what they are?  That would seem to be the most intuitive to me. </p>

```<code>function myFunc(recentDate, oldDate)
</code>```

Title: Should the most recent date be named 'start' or 'end'?

Body:
So I have a function that takes two dates.  The SQL query gets all the results between the two dates.  I currently have my function setup as such:

```<code>function myFunc(start, end)
</code>```

Where start is the most recent date and end is the oldest date.

Is this intuitive/correct or is there another naming/ordering convention I should be using?

Body:
Why not just name them what they are?  That would seem to be the most intuitive to me.

function myFunc(recentDate, oldDate)


答:
In the normal course of business, time only works in one direction, and "start" generally comes before "end". I'd be inclined to make "start" the earliest date in the range and "end" the latest. But if your query simply searches for anything between the two dates and doesn't depend on them being in order (which would make for a more robust, easier to use function) then it shouldn't really matter what you call them.

It's obviously easy to add that feature to your function. Just have the function compare the two dates and swap them if they're not already in the order that it requires. You might also give the parameters more generic names like date1 and date2 to help convey to users that they just need to supply two dates and not worry about the order.


答:
Really, who cares.  It's a date range, you want everything between the two dates.  No matter the names, someone will screw up their usage.

And your code wants start to be the recent date, and end to be the oldest.

So, at the start of your function switch them around if they are backwards.

```<code>var tmpStart = start;
var tmpEnd = end;
start = (tmpStart < tmpEnd) ? tmpEnd : tmpStart;
end   = (tmpStart < tmpEnd) ? tmpStart : tmpEnd;
</code>```

I personally would use from, and to instead of start and end.

Body:
Really, who cares.  It's a date range, you want everything between the two dates.  No matter the names, someone will screw up their usage.

And your code wants start to be the recent date, and end to be the oldest.

So, at the start of your function switch them around if they are backwards.

var tmpStart = start;
var tmpEnd = end;
start = (tmpStart < tmpEnd) ? tmpEnd : tmpStart;
end   = (tmpStart < tmpEnd) ? tmpStart : tmpEnd;

I personally would use from, and to instead of start and end.


问:
Algorithm for finding overlapping times
Part of our ERP system is a sub-system for running background jobs.  We track a variety of meta-data about our jobs in a table including timestamps for submitted, started, and end times.

I'm creating a report showing the performance of our job system, detailed by day. One KPI is maximum # of jobs running at once.  The algorithm I'm currently using is:

```<code>dim cnt as integer    'number of overlapping jobs
dim max as integer    'maximum number of jobs running at one time

for each Job where
         Job.SubmitTs = today

  'bJob is a 2nd instance of Job
  for each bJob where
           bJob.SubmitTs =  today and
           bJob.StartTs  <= Job.EndTs and
           bJob.EndTs    >= Job.EndTs
    cnt = cCnt + 1
  next

  if cnt > max then max = cnt
next
</code>```

The problem with this algorithm is that it is very slow due to all the looping.  I was wondering if there is a faster way to implement this?

Edit
I cannot use SQL queries to access the data.

答:
Include all the start and end points (in time) of the Jobs in an array (this creates 2*N elements (1 for start 1 for end))

sort the array ordering by the timestamp of the event,

then iterate over the (2*N) elements as follows:

```<code>for each element X
do
  if(X.type == start)
    counter++
  else
    counter--
  ans=max(ans, counter);
end
</code>```

Complexity: O(n.log(n)) for initial build of the sorted structure + O(n) for the iteration through its elements.

Edit: It has been suggested by Giorgio that an array is used, which is a better option. (The suggestion originally was to use a red/black tree, but no task removing capability seems to be needed, so maintaining order is trivial).

Title: Algorithm for finding overlapping times

Body:
Include all the start and end points (in time) of the Jobs in an array (this creates 2*N elements (1 for start 1 for end))

sort the array ordering by the timestamp of the event,

then iterate over the (2*N) elements as follows:

for each element X
do
  if(X.type == start)
    counter++
  else
    counter--
  ans=max(ans, counter);
end

Complexity: O(n.log(n)) for initial build of the sorted structure + O(n) for the iteration through its elements.

Edit: It has been suggested by Giorgio that an array is used, which is a better option. (The suggestion originally was to use a red/black tree, but no task removing capability seems to be needed, so maintaining order is trivial).


问:
Why do some open source projects do not accept pull requests, but emailing patch files only
Why do some open source projects not accept pull requests, but require contributors to email patch files only?
e.g. Git
Although they publish code in github or other distributed scm hosting.
It is not interactive nor convenient to send patch files.
Patch file is an old-fashioned way.
Pull requests are interactive. Other people may also discuss.</p>

答:
It depends on who is in charge of accepting your pull request.

If it is Linus Torvalds, well... a good old patch is preferable:

I don't do github pull requests.

github throws away all the relevant information, like having even a valid email address for the person asking me to pull.

The diffstat is also deficient and useless.

Git comes with a nice pull-request generation module, but github instead decided to replace it with their own totally inferior version.

As a result, I consider github useless for these kinds of things.

It's fine for hosting, but the pull requests and the online commit editing, are just pure garbage.

I've told github people about my concerns, they didn't think they mattered, so I gave up. Feel free to make a bugreport to github.

He details:

In order for me to pull from github, you need to:

(a) make a real pull request, not the braindamaged crap that github does when you ask it to request a pull:

real explanation,

proper email addresses,

proper shortlog, and

proper diffstat.

(b) since github identities are random, I expect the pull request to be a signed tag, so that I can verify the identity of the person in question.

I also refuse to pull commits that have been made with the github web interface.

Again, the reason for that is that the way the github web interface work, those commits are invariably pure crap.

Commits done on github invariably have totally unreadable descriptions, because the github commit making thing doesn't do any of the simplest things that the kernel people expect from a commit message:

no "short one-line description in the first line"

no sane word-wrap of the long description you type: github commit messages tend to be (if they have any description at all) one long unreadable line.

no sign-offs etc that we require for kernel submissions.

github could make it easy to write good commit messages and enforce the proper "oneliner for shortlogs and gitk, full explanation for full logs".

But github doesn't.

Instead, the github "commit on the web" interface is one single horrible text-entry field with absolutely no sane way to write a good-looking message.

When challenged on the text area for commit messages:

@torvalds The GitHub commit UI provides a text area for commit messages.

This supports new lines and makes it easy to do nicely formatted commit messages :)

No it doesn't.

What it supports is writing long lines that you have not a f*cking clue how long they are.

The text area does not do line breaks for you, and you have no way to judge where the line breaks would go.

In other words, it makes it very hard indeed to do "nicely formatted commit messages".

It also doesn't enforce the trivial "oneliner for shortlog" model, so the commit messages often end up looking like total crap in shortlogs and in gitk.

So the github commit UI should have

separate "shortlog" one-liner text window, so that people cannot screw that up.

some way to actually do sane word-wrap at the standard 72-column mark.

reminders about sign-offs etc that some projects need for project-specific or even legal reasons.

ContentLicense: CC BY-SA 4.0


问:
Origin of structures and classes
What design and implementation issues did programmers have to solve when they decided first to use structures and classes?

When did this happened and who were the pioneers behind these ideas?

Note, this is double question, because structures and classes are related. I realize that structures are quite older than classes. It would be great if the answer would talk separately about both of them and cite some sources.

答: "structures" are actually completely different from "classes".  Think of the old style "struct" as a record.  In QBASIC they were even called that.  The necessity of this is pretty obvious and though I can't say who invented it...I'd imagine it came up almost immediately.  OOP "classes" seems to have fairly well started with Simula: http://en.wikipedia.org/wiki/Object-oriented_programming#History</p>

Title: Origin of structures and classes


答:
You'll want to look at Garbage Collection is Fast, But a Stack is Faster, a paper about using what C programmers would think of as "heap" for the stack frames in compiled C.  I believe the author tinkered with Gcc to do that.  It's not a definite answer, but that might help you understand some of the issues with recursion.

The Alef programming language, which used to come along with Plan 9 from Bell Labs, had a "become" statement (See section 6.6.4 of this reference). It's a sort of explicit tail-call recursion optimization. The "but it uses up call stack!" argument against recursion could potentially be done away with.


答: You can find information on structures in this Wikipedia article. In short they seem to be so deeply anchored in computer science, that they were supported first by hardware (special instructions in IBM 1620, punch cards basically as one record instance, and Babbage's Analytical Engine (at least according to wikipedia). COBOL was the first widely used language to support the construct.</p>

Title: Origin of structures and classes

Body:
What design and implementation issues did programmers have to solve when they decided first to use structures and classes?

When did this happened and who were the pioneers behind these ideas?

Note, this is double question, because structures and classes are related. I realize that structures are quite older than classes. It would be great if the answer would talk separately about both of them and cite some sources.


答:
Structures are groups of data, typically typed. COBOL saw the first widespread usage of them. Though analogs to that existed beforehand. The design issue here is grouping multiple sets of data together like a name, a occupation, and a phone number. The idea of a "record" is something much older than computing and shows up in mathematics and a host other disciplines.

Object Oriented Programming was originally designed to deal with simulation where you'd have a bunch of objects running to simulate a system. Simula 67 was the first to implement that style of programming. Smalltalk was the first fully object oriented language where everything is an object including primitives. The original issue being solved was the simulation of complex systems. Simula 67 was designed by Ole-Johan Dahl and Kristen Nygaard. Alan Kay (who once answered a question on Stack Overflow) designed Smalltalk which is still used.

Structures and Classes are related fairly closely to types in that they both define certain parameters for a set of data. Classes take it further defining access permissions and operations thus allowing fully implemented Abstract Data Types. Structures can be thought of a subset of Classes in an object oriented language. They'd be a wrapper class that has all the fields set to public and no methods outside of getters and setters for those fields.

Title: Origin of structures and classes


答:
I think start shouldn't be used. To Start and to Stop, not to Start and End.
I think you can use Begin and End together but that can be confusing again from which point of reference you looking at Begin.

I use function(FROM, TO) for more correct English perhaps. But in any case, you should place a wrapper logic in your function which sets the earliest date properly:

```<code>if FROM is earlier than TO
 t_earliestDate = FROM
 t_latestDate = TO
else
 t_earliestDate = TO
 t_latestDate = FROM
</code>```

Body:
I think start shouldn't be used. To Start and to Stop, not to Start and End.
I think you can use Begin and End together but that can be confusing again from which point of reference you looking at Begin.

I use function(FROM, TO) for more correct English perhaps. But in any case, you should place a wrapper logic in your function which sets the earliest date properly:

if FROM is earlier than TO
 t_earliestDate = FROM
 t_latestDate = TO
else
 t_earliestDate = TO
 t_latestDate = FROM


答:
You are defining a time span. A time span has a start and an end (or begin and end). It doesn't have a "most recent" and "least recent" because this calls to the notion of "present", which is not relevant.

Further adding to the notion of "no time like the present", the start and end can be both in the past, both in the future, or one before and one after the present. Suddenly "most recent" becomes a lot more complicated.


问:
Can the user not manipulate html elements which are disabled for non-permitted user
With todays browser extensions/tools is it not easily possible for a user to edit the html/css settings of a website and so enable some disabled buttons etc... to gain access to not permitted areas?</p>

答:
Yes it's possible to manipulate anything in the client side, which includes HTML, CSS, and JavaScript. However the original client side code is stored in the server, and while you can manipulate it, if you do not have access to the server you can not save your changes. Refreshing your browser essentially means requesting a fresh copy of the client side code, so all changes to your local copy will vanish.

As for restricted areas, let's say for example a login form. While you can change the colors and/or size of the password input box, the code that validates whether the password is correct resides on the server, you have no access to it, and your client side changes doesn't affect it, so there's nothing to worry about.


答:
It depends on what those files contain.

For example, let's say that person A has a website. This website has a link (or button or whatever) to some web page which should only be available to administrators, with stuff used in debugging (like clearing the database for example). When he the site goes live, he decides that instead of removing the link and the debugging code, he only comments out the link and leaves in the debugging stuff. Boom! You can imagine that anyone can see the comment by viewing the source of the page in any browser.

But then again, this type of things only happen because of human error (and maybe stupidity). I for one haven't seen this stuff ever in my life and would be amazed if I ever did.

If you build a website right and don`t leave any nasty stuff in your code then you are all fine.

When you visit a website you only get files which describe what you see on the screen. As for the functionality (scripting) part, these come in two different flavors. First there is the client side scripting and unless you want to harm yourself, there's not much you can do with it. Second, there is the server side scripting which does contain code for connecting to the database and retrieving information and such, but you NEVER receive it (secrets :P).

In the end, there are possibilities for bod things to happen from html and css but you really, really, really have to go out of your to enable them.

Title: Can the user not manipulate html elements which are disabled for non-permitted user

Body: With todays browser extensions/tools is it not easily possible for a user to edit the html/css settings of a website and so enable some disabled buttons etc... to gain access to not permitted areas?</p>


问:
TDD: Am I doing it right?
I'm a new programmer (only been learning for about a year) and in my goal to become better at it I have just recently learned about TDD. I wanted to get into the habit of using it since it seems very helpful. I wanted to check and make sure I'm using it correctly.

What I'm doing:

Think of a new method I need.

Create a test for that method.

Fail test.

Write method.

Pass test.

Refactor method.

Repeat.

I'm doing this for EVERY method I write, are there some I shouldn't bother with? Later on I usually think of a way to test my already existing methods in a different way or situation. Should I make these new tests I think of, or since each method already has a test of their own should I not bother? Can I be OVER testing my code I guess is my main concern in asking this.

EDIT

Also, this was something I was just wondering. When doing something like making a GUI, would TDD be necessary in that situation? Personally, I can't think of how I would write tests for that.

答:
There are some methods that aren't being tested, namely those tests.  However, there is something to be said for some tests being added after the initial code has been written, such as boundary conditions and other values so that there may be multiple tests on a single method.

While you can over test your code, that usually comes where someone wants to test every possible permutation of inputs which doesn't quite sound like what you are doing.  For example, if you have a method that takes in a character, do you write a test for every possible value that could be entered?  That would be where you'd get to overtesting, IMO.

Title: TDD: Am I doing it right?


答:
Generally you are doing it right.

Tests are code.  So if you can improve the test, go ahead and refactor it.  If you think that a test can be improved go ahead and change it.  Do not be afraid to replace a test with a better one.

I recommend in testing your code, avoid specifying how the code is supposed to do what it is doing.  Tests should look at the results of the methods.  This will help with refactoring.  Some methods do not need to be explicitly tested (i.e. simple getters and setters) because you will use those to verify the results of other tests.

Title: TDD: Am I doing it right?

Body:
I'm a new programmer (only been learning for about a year) and in my goal to become better at it I have just recently learned about TDD. I wanted to get into the habit of using it since it seems very helpful. I wanted to check and make sure I'm using it correctly.

What I'm doing:

Think of a new method I need.

Create a test for that method.

Fail test.

Write method.

Pass test.

Refactor method.

Repeat.

I'm doing this for EVERY method I write, are there some I shouldn't bother with? Later on I usually think of a way to test my already existing methods in a different way or situation. Should I make these new tests I think of, or since each method already has a test of their own should I not bother? Can I be OVER testing my code I guess is my main concern in asking this.

EDIT

Also, this was something I was just wondering. When doing something like making a GUI, would TDD be necessary in that situation? Personally, I can't think of how I would write tests for that.