问:
How to apply good Object Oriented Design principles in Embedded Systems
I am a firmware engineer moved from Electrical background to Embedded Systems. I was till now programming in C and never bothered to apply OO principles in my design. Recently I was forced to implement design in C++. I started liking the OO principles like SOLID, design patterns, etc. I wanted to know more about applying OO design in my firmware design. All the resources on OO, that I found were too much into application programming rather than firmware. I found this book relevant (ordered it). I was curious if there are any other resource that can help me learn OO principles with a focus on embedded systems.

I am still new to OO world, so please suggest me if I should learn OO principles first and then learn about applying them for embedded systems or start learning only stuff relevant to embedded system.

答:
About 8 years ago I was faced with a similar issue.  I had just started a role working with embedded technology, having previously spent several years doing object orientated programming in C++.

I was never particularly successful in bringing application techniques to device driver code.  I did manage to write some useful classes for abstracting away I/O bus widths, processor bits size and bus driver implementations, but the reality was that it made life much more confusing for the other members on the team.

Think of it like this: most embedded software engineers have been in the industry for a good many years. They are used to dealing directly with bits, bytes, and manipulating memory, and that's the focus of their work. Getting the right bits to the right memory address. My attempts at using OO to abstract away these details just hid the key details. It made it harder for the hardware engineers to see what was happening, and the other C programmers didn't see any benefits over "just being obvious"

By the sounds of it, in your environment, you are being actively pushed in the C++ direction.  so its quite possible that you will not have these issues, but also watch out for the drop in the portability of the C++ code.  not all low level environments will allow C++ code to use used, and the "Standard Template Library"'s use of the word Standard is rather loose, particularly when moving between different compilers.


问:
Is Perl still a useful, viable language?
I know it may have been asked before, but here goes nothing...

Is Perl still something that would be considered useful? If someone was a new programmer (either completely new to programming or just a few month/years of experience) would Perl be something to be considered worthwhile to learn?

Is Perl still used with frequency? Is it still popular?

Or is Perl dying out compared to languages like Python, Ruby, PHP, ASP.NET, etc.?

Basically it boils down to this:

Is it still used/is it still used frequently? If yes, is it dying? If no, will it make a come back?

Is it something that would be worth learning?

How does it compare in demand to languages like Python in both popularity and usability/viability? Could languages like Python or Ruby be considered replacements for Perl?

Also, will newer versions of Perl really bring a large improvement to the Perl community, and perhaps bring Perl back to centerstage compared to other languages?

EDIT:

Okay, I suppose here's a better, reworded question:

Is Perl still growing, or is it "dying"? Is it still a language worth learning and using? What projects does it really "shine" in compared to other languages? What makes Perl a language to choose? Essentially: is Perl growing obsolete compared to other languages, and if so, do you expect that to change, or to continue?

And thank you to everyone who has answered so far, the discussion has been really interesting!

答:
Perl has its place.  Its "bad reputation" is generally due to it allowing you great flexibility to do things that should really be done by a different tool.

If you ask yourself the question "What am I trying to achieve? And are there appropriate tools to deliver this?" then you are part of the way there.

If you are writing a quick script, then using a scripting language makes sense.  If you are wanting to create a complex application, then you "could" write it in Perl, but you probably shouldn't.

However, as your question relates to a newish programmer, may I suggest leaving Perl alone for now. Simply because you will learn fewer bad habits from a less flexible language.

ContentLicense: CC BY-SA 3.0


答:
The main thing Perl still has going for it is CPAN - there are so many pre-written modules that it's very easy to find something you need.

That said, I would not learn Perl. Perl is a great language for people who know it already (like me), but Python seems to be (from my outsider's perspective) a better language for doing the sort of quick and dirty file and text parsing stuff that Perl used to be the "go-to" language for.

Title: Is Perl still a useful, viable language?

Body:
I know it may have been asked before, but here goes nothing...

Is Perl still something that would be considered useful? If someone was a new programmer (either completely new to programming or just a few month/years of experience) would Perl be something to be considered worthwhile to learn?

Is Perl still used with frequency? Is it still popular?

Or is Perl dying out compared to languages like Python, Ruby, PHP, ASP.NET, etc.?

Basically it boils down to this:

Is it still used/is it still used frequently? If yes, is it dying? If no, will it make a come back?

Is it something that would be worth learning?

How does it compare in demand to languages like Python in both popularity and usability/viability? Could languages like Python or Ruby be considered replacements for Perl?

Also, will newer versions of Perl really bring a large improvement to the Perl community, and perhaps bring Perl back to centerstage compared to other languages?

EDIT:

Okay, I suppose here's a better, reworded question:

Is Perl still growing, or is it "dying"? Is it still a language worth learning and using? What projects does it really "shine" in compared to other languages? What makes Perl a language to choose? Essentially: is Perl growing obsolete compared to other languages, and if so, do you expect that to change, or to continue?

And thank you to everyone who has answered so far, the discussion has been really interesting!


答: The popularity of a language has very little to do with its viability or usability.  Perl is still a very usable language.  Its reputation, deserved or otherwise, as being unfriendly to newbies eventually meant no one new would learn it if they could help it.  The only reason I don't use it anymore is that no one else I know uses it anymore.</p>


问:
What advantages would the Twitter streaming API provide?
I'm in the very early stages of writing an application to mine through Twitter data looking for certain types of information.  I've been using Twitterizer, which I have found effective in downloading the information (it provides interfaces to the "old" REST based API, and the newer streaming one).

This would only be for personal use, so I don't think I would max out the number of API calls per hour on the old API, and it seems as though the streaming API is slightly slower.  On the surface, it seems like the REST would suit me better, but I'm wondering if I'm missing any hidden advantages to using the streaming API that could benefit my application.

答:
If your goal is to get information as it comes into the system, use the API designed for that - with the streaming API you have a persistent connection and the message will appear in your stream immediately with minimal overhead.

You can get the same information running single queries, but you would need to deal with polling intervals and duplicate messages.

If running searches on recent rather than new data provides the result you need, the streaming API may well seem slower - while data is added to twitter very quickly, it is not as fast as retrieving data that is already in place.


答:
Mining real-time trending topics would be an idea that takes advantage of the Twitter Streaming API.
I had tried to develop a tool like that sometime ago. I don't know about now, but back then only 1% of the tweets was available in the streaming API, which made it quite difficult to construct valid and meaningful trending topics. The low volume of available tweets and their geographical sparsity were the reasons I dropped the project. </p>

Title: What advantages would the Twitter streaming API provide?

Body:
I'm in the very early stages of writing an application to mine through Twitter data looking for certain types of information.  I've been using Twitterizer, which I have found effective in downloading the information (it provides interfaces to the "old" REST based API, and the newer streaming one).

This would only be for personal use, so I don't think I would max out the number of API calls per hour on the old API, and it seems as though the streaming API is slightly slower.  On the surface, it seems like the REST would suit me better, but I'm wondering if I'm missing any hidden advantages to using the streaming API that could benefit my application.


问:
Which CS courses are a "must" for a web developer
My goal is to learn how to program a website with Python/Django in the next year. From what I've understood, I also have to learn HTML, CSS, JavaScript.

I understand in order to build a website, I will need to find a co-founder whose skills far exceed mine. But still, the situation will be way different if I'm a person who's closer to his/her level and has dedicated a lot of time teaching himself than every other "I have an idea, just need a tech co-founder" type of guy.

I do plan to pursue a degree in computer science, but after finishing high school last May decided to take an year off, so I am free to learn programming in the next 10 months.

For now, I have the chance to attend some college courses in a top institution. Which ones are a must for a web developer so that I don't have any gaps in my understanding of programming and write "sophisticated code"?

EDIT:Thank you all for the help!From the courses suggested I may be able to attend some/none/all of OOP(with Java),Networks and Graphics,SE-Algorithms,Discrete Math for Comp.Scientists,Databases,Information Retrieval and Data Mining.Which of those are more important for Web development with Django?

I've read a lot of times people saying that self-taught programmers had gaps in their knowledge, didn't write clear code.This is why I'm asking which CS courses can fill those gaps? Not only in practical skills,but in mindset,way of thinking.

答:
Web development should not be considered separate from any other development.  You need a quality foundation no matter what - data structures, imperative programming, object oriented programming, other types of languages, software engineering, and so on.  You can then take courses that may be better geared toward web development.

If you were just learning on your own time, it might be worth learning specifically Python. Since you are asking about courses to take though, I would not waste your money on a course about a specific language.  Once you have the theory down (as mentioned above), you will find it easy to learn Python, or any other language for that matter, on your own.  Or, if you're feeling up to it, do both at once - take a class and learn Python in your spare time.

EDIT: You mentioned: OOP(with Java),Networks and Graphics,SE-Algorithms,Discrete Math for Comp.Scientists,Databases,Information Retrieval and Data Mining

I suggest this ordering:

1) OOP (if you know the basic concept already, can take later)

2) Discrete Math

3) Databases

4) Information Retrieval and Data Mining

5) Network and Graphics - that combination sounds strange to me, which makes me skeptical of the quality of the course.  Read the course description.

6) Algorithms - requires Discrete & OOP (or some kind of programming) at the least.  Check pre-reqs listed in course catalog if you haven't already.

EDIT2: I should say OOP could be taken after Discrete, but many students find Discrete Math difficult without an application for it in mind and OOP (or any other programming) will give you that application.


答:
First of all, it's always better to disambiguate.

Businesses talk about Perl 5 when talking Perl, but on a far-far
  land, beyond deep-thinking island, the design-by-committee tribe is
  still cooking a hefty slab of Perl 6 (and it's almost ready, with an
  engine written in Haskell and powered by the tears of the gods)

Ok, that said, what is Perl 5 used for, today?

legacy web systems / intrawebs - some just won't die

data mining / statistical analysis - the perl regex engine, even if slightly outdated, (PCRE, a spinned off library, tops it up in any possibile way and it's the default PHP engine) is still good for simple analysis

UNIX system administration - Perl shall always be installed on UNIX.

You can count on it being readily available even on Mac OS X.

network prototyping - many core network experts learned Perl when it was all the
rage; and they still do their proofs-of-concept with it.

security - many security experts, too, need fast prototyping. (and fast automated fixes) Perl can, and does, cover for that.

The extensive CPAN collection is very handy, when dealing with prototypes.

(Batteries may not be included, but they're still right there, on the shelf)

Remember drawbacks, though:

Object support in Perl sucks hard, you bless references and do unholy stuff in the name of objects, then wonder why you took all the trouble in the first place.

Reading other people's Perl is more than a craft, it's science, and a painful one, too.

Perl is nifty, it makes you think nifty, it makes you feel nifty, you become a programming rockstar. Now, think about getting up, and going to work in a office full of rockstars: it's a "boat that rocks" hard. Expect wild fluctuations.


问:
Explaining technical things to non-technical people
I often have to explain technical things and technical decisions to my extremely non technical manager and I'm pretty awful at it. What are good ways to essential dumb things down for the rest of the world who don't have a passion for programming?

Example questions I've been asked:

Why are you using Django instead of Java (Didn't accept that it was cheaper either)

Asking me to rephrase things in non technical words, my sentence was "Certain HTML tags are not allowed". How can I possibly dumb that down?

Other stuff that makes perfect sense to me, but is just so basic I don't know how to explain it

Why this, why that, why everything!

Also, how do I tell my manager to look the basic stuff up on Google, like "What is Pylons?"

答:
Once, long ago whilst still an undergraduate, I was asked to explain something over Sunday lunch - one of the most educational experiences I've ever had. The person asking the question was demonstrably not stupid - but had no background, the level of knowledge I assumed just wasn't there. I started to answer, got a blank look, changed down, still blank, changed down again, still blank... hmm... so I started the same way you start to build an application, with little blocks of explanation that you can build into something more substantial.

The key part of this lesson, for me, was (and is) just how much we assume (not just programmers, everyone) about other people's knowledge of our chosen speciality whereas in fact, even, you might reasonably assume that the majority of people know that 1 + 1 = 2 but after that it gets interesting.

So the first and most important thing to grasp is that people don't know and don't understand what you do - but they do understand what they do and when you're explaining stuff you therefore need to start simple and stay at an appropriate level for your audience.

In terms of specific techniques -  I think that @Josh K has it pretty covered - and I'd emphasise that Analogies are an absolute winner.

One more thing - it may be, from time to time, acceptable to just write things off as "geek stuff" people don't always want full explanations of why and if you've previously demonstrated a willingness to explain and a capability to do so in an understandable manner then people will be inclined to trust you when you suggest that "complex technical reasons" apply or that ultimately you can achieve a particular result by "doing geek stuff" (or "programmer stuff" or whatever term works well in your environs).

Communicating technical things to a non technical audience (of one or more) is a skill, one that you can develop and one that you need.

ContentLicense: CC BY-SA 2.5


问:
Scala: From concept to working
Second attempt to ask my question more concisely.

I want to say I am a Scala fan, or at least I want to be.  I've resigned myself to learning one of these functional languages [Scala, Haskell, Erlang].  I've dabbled in all of them, far and away I have spent the most time trying to understand Scala.  I've honestly used the tutorials for Haskell and Erlang more as a tool for greater understanding in Scala.  I do believe that I have on some level an understanding of the basics.  But, the reason why I thought I wanted to go with Scala is proving to be the most fustrating ...

The verboseness of most Java libraries are ... umm yeah, SNMP4j makes me want to rip my hair out.

So here we go, does anyone know of a site or tutorial similar to "Write Yourself a Scheme in 48 hours." Something that really shows how you go from concept to working project including interpreting some third party libraries.

Or is Scala truthfully just a better Java? Meaning that it's best to learn Java before attempting Scala.

I didn't mean to infer that Scala wasn't a language in it's own right.  On the contrary, I feel that it is a very good language; however, the bill of sale for Scala IS that it is better at Java than Java.  So I am really trying to answer for myself how viable it is to learn Scala, while I really don't have much of an interest in learning a lot of Java.  I want to use the libraries since there is the biggest advantage, as perceived by some, in using Scala.

If some of these library implementations are so 'complex' that they require, not just are best benefited by, having a good grasp of Java programming idioms, then I would like to know that I've been approaching this problem from the wrong direction.

I realize there are some good examples of some libraries that have been 'scalifed' or what have you.

答: I don't know Scala, but you could try doing some of the bigger exercises in Real World Haskell, in Scala. If RWH refers to a particular library for, say, parsing XML, find an equivalent one and try to write idiomatic Scala that's equivalent to the Haskell in their examples.</p>

Title: Scala: From concept to working


问:
How clean should new code be?
I'm the lead designer in our team, which means I'm responsible for the quality of the code; functionality, maintainability and readability.

How clean should I require my team members' code to be if we are not short on time?

In my view, we should clean up old code we modify; adding a line to a method means you clean up that method.

But what about new code?

We could make it sparkling clean, so that if another coder comes along tomorrow and makes a small modification, she doesn't have to clean it up at all. But that means if no-one ever reads that piece of code again, we've wasted time making it sparkling clean.

Should we aim for "almost clean" and then clean it up further on future visits? But that would mean not getting the full value for the understanding we had when we wrote it in the first place.

Right now, I'm going for "sparkling clean"; partly as a tutorial for my colleagues who are not as picky as I.

答:
I've always had a drive to not repeat myself in code--I consider it the single most important drive in good code--nearly everything else derives from this.

In doing so I've found that refactoring code to eliminate redundancy is one of the most educational practices as well.  Over time I've learned to recognize more things as redundant as well as more patterns and tricks to use to refactor them away.

On top of that, code-combining refactorings stack like you wouldn't believe.  You start at the inside and refactor a handfull of similar statements to use a data structure, that allows you to identify similarities with other pieces of code and it rolls uphill with surprising speed, reducing code by the bucketful on the way.

So why wouldn't you do this wherever you had the chance, even if you didn't have lots of extra time?

Most of the extra "Clean" in your code such as formatting and comments comes from this process as well--who wants to document 5 pages of repeated code?  As you isolate them into a single function, NOW they are worth documenting!

Title: How clean should new code be?


答:
I learned Perl 4 and 5 while doing system administration back in the 90'es.  Today I do Java programming (where invoking Perl is usually not desirable), and I still use Perl once in a while on my development computer.  This is usually solely to do datamining on log files where the regular expressions in Perl and the scaffolding for text parsing oneliners in Perl make it very easy to do on a command line.

Essentially I use it today as awk on steroids.  For this it is brilliant.

One of the features of Perl is that there is more than one way to do almost everything.  This allows you to choose the one that fits with your way of thinking - which is great when just hacking together a oneliner or two, but not so great when having to understand other peoples Perl code as they usually choose some other way to do it which fits with their way of thinking.

I would consider Perl a very useful tool which you may want to learn if you focus on just what the regular expressions can do to help you sift through your text files. Stay away from anything to do with objects.


问:
What are some alternative methods to IronPython for calling Python code from .NET?
There are some great libraries for Python that have cousins in the .NET world, but some are unmatched.

Realizing that Python is a dynamic language, which makes it difficult to mix with a (largely) statically typed language like C# (though this is seemingly getting easier with .NET 4.0), there are options like IronPython which can help match up the two languages.

I've never come across any other options for dovetailing Python libraries with .NET.  Are there any other ways to do this that are tried and true?  I have far less experience with Python, so it's entirely possible that I'm overlooking something.

答: IronPython tries the total integration approach. There is a package called Python.NET that is a hybrid of the CLR and the standard C based Python runtime. It seems less developed than IronPython and I'm not sure it would be ".NET" enough. However, it would give direct access to Python libraries.</p>


答:
The key is to clean up the code you are most likely to work in again.

Working in well-factored code is more fun and more likely to produce the desired result. Those are both important.

However, refactoring takes time, and all edits carry risk of new bugs. Refactoring code that you don't otherwise need to work in is a bad idea.

How to know what code you need to work in? Changes tend to happen together, in high-churn areas, while other areas are left idle for a long time. There are many reasons for this phenomon; one is that the changes you make right now are probably wrong, but you can't know that until they're done.

So, I use the following sequence when working on a feature or bug fix:

Imagine what the code would look like if it was ideal for the change I want to make, so that the change would be a simple one-line edit that was obviously correct?

Imagine a path of refactorings to get things to that point.

Make one refactoring at a time, testing as I go, and checking in each refactoring separately, with a special change description that starts with "REFACTORING:". This helps make it obvious that if you're looking for a deliberate behavior change, you don't have to look at this one. Also, since most refactorings are well-defined with well-known names, it is easy to understand these changes later.

Make the single one-line edit to get the desired functionality change.

This approach works just as well for changes to existing functionality as it does for adding new functionality, as everything is existing code after day 1. However, if you're branching in to a new area of functionality for your program, it may make sense to throw a quick-and-dirty implementation together to get real feedback on your plans.

There are many caveats:

If a deadline is looming, the risks of refactorings may outweigh the benefits. Judgement is required.

Sometimes the code would require extensive refactoring to make this work, but it would be possible to implement the desired feature or bug fix easily enough. In this case, I may do the more obvious, straightforward refactorings but not the ideal described above.

If I don't have high-quality automated tests, the risks of refactoring are more concerning. I may refactor less, depending on the circumstances. However, poorly-factored code is also difficult to unit test, so it's easy to end up in a quagmire if you're not careful.

Note that I avoid refactoring towards structure that I think will be beneficial for some future change that I can't be sure I'll need. Refactor for the issue at hand only. However, if this is not the first time I've needed to make this kind of change, I may broaden the scope of refactoring in anticipation of future similar changes. Judgement required, again.

Title: How clean should new code be?

Body:
I'm the lead designer in our team, which means I'm responsible for the quality of the code; functionality, maintainability and readability.

How clean should I require my team members' code to be if we are not short on time?

In my view, we should clean up old code we modify; adding a line to a method means you clean up that method.

But what about new code?

We could make it sparkling clean, so that if another coder comes along tomorrow and makes a small modification, she doesn't have to clean it up at all. But that means if no-one ever reads that piece of code again, we've wasted time making it sparkling clean.

Should we aim for "almost clean" and then clean it up further on future visits? But that would mean not getting the full value for the understanding we had when we wrote it in the first place.

Right now, I'm going for "sparkling clean"; partly as a tutorial for my colleagues who are not as picky as I.


问:
C Language - K&R 1st vs 2nd Edition?
I'm planning to buy a book to learn C Language. Many say K&R is a must-have book for C programmers so I chose it. I see that there are two editions. What are the differences between them?</p>

答: Definitely the 2nd version. The first version doesn't cover ANSI C.</p>

Title: C Language - K&R 1st vs 2nd Edition?


答: Our application shells out to run python. We had to do that instead of using IronPython because a number of the base libraries are compiled from C. A simple test for determining what you'll have to do is to parse a CSV file. </p>

Title: What are some alternative methods to IronPython for calling Python code from .NET?

Body:
There are some great libraries for Python that have cousins in the .NET world, but some are unmatched.

Realizing that Python is a dynamic language, which makes it difficult to mix with a (largely) statically typed language like C# (though this is seemingly getting easier with .NET 4.0), there are options like IronPython which can help match up the two languages.

I've never come across any other options for dovetailing Python libraries with .NET.  Are there any other ways to do this that are tried and true?  I have far less experience with Python, so it's entirely possible that I'm overlooking something.


问:
Is the agile approach too much of a convenient excuse for cowboys
I believe that an agile approach is best for projects where the requirements are fuzzy and a lot of interaction is required to help shape the end user's ideas.

However... In my professional work, I keep ending up at companies where an "agile" approach is used as an excuse as to why no effort was put into an up front design; when the requirements are well understood.

I can't help but thinking that if the agile approach wasn't around, I'd be sitting here with a nice high-level specification and not having to revisit the same screen and functionality every second day when something else crops up or so and so hadn't thought of that.

Are the benefits of agile methodologies really enough to outweigh the excuse for being lame it gives to cowboy technical leads?

Update: Ironically I'm now a certified Scrum Master. One of the papers presented on the Scrum course observed that the best development process was one where there was a single expert or guru making the design decisions, however that has obvious weaknesses. Scrum shifts the responsibility for producing quality software to the "Team" which means a sub-standard team can get away with churning out spaghetti which I guess is no different to other Agile and non-Agile development processes.

答: I found that users can only give us feedback once they have an application they can use, screens they can enter data on. Only then, they truly understand what we were trying to say in the requirements documents (that clients sign but everybody have its own version of the meaning). If it is not an agile development, it is going to be a waterfall project going over budget but the application is going to change once you deliver it. Your first version is no more than a prototype for users to discuss what the requirements should have been. So I rather call it agile than over budget.</p>


答:
There may be a few cases where a first edition is preferred for some reason or other, but this is definitely not one of them.

If you want to learn C, the second edition is clearly preferred in this case. The first edition teaches a version of C that's been obsolete for decades. C has maintained enough backward compatibility that most of the code in the first edition will probably still work with a current compiler, but it's definitely not written the way you want to write C code any more.

Title: C Language - K&R 1st vs 2nd Edition?

Body: I'm planning to buy a book to learn C Language. Many say K&R is a must-have book for C programmers so I chose it. I see that there are two editions. What are the differences between them?</p>


答: The second edition is written to ANSI C, which the first predated. That alone should make the second book the one to buy.</p>

Title: C Language - K&R 1st vs 2nd Edition?


答:
When I decided to learn Perl as my first language a few years ago there were a number of factors that guided my decision:

is there a lot of good reference material on the language?

can I easily find help with my questions?

is the language in active use by a large diverse population?

are there active projects that will help me with my goals?

For me the answer was yes. I'm a graphic designer. I learned HTML and CSS years ago but needed to upgrade my skills after clients wanted more from their websites. I had used various php frameworks which gave me the bug to really learn to program. I did a lot of research and found well supported projects like Template Toolkit as well as new ones like Perl Dancer and Mojolicious. The documentation that comes with Perl has been very helpful as well as the library of publications.

I have found the Perl mail lists pretty friendly to beginners and active. On PerlMonks people from all over the world come with questions and answers for a wide range of applications. There are several active Perl news sites, blogs and streams. These resources have taught me a lot about Perl and programming.

Granted, that is MY experience. I don't know exactly how many people log on to these sites, subscribe to the mail lists or build their web applications, for example, using Perl. I also can't comment on how much better or worse my experience would have been had I chosen another language to start off with. I don't doubt I could find many of the same positive aspects in the communities of other languages. I can say I'm still happy with the choice I made.


答:
In my opinion, after working with Perl again after a few years of nearly not using it, it is better than ever. Perl 5 has a lot of awesomeness in CPAN, even OO can be done right now. (Have a look at Modern Perl)

Perl 5 is far from dead. Just have a look at some Perl websites and CPAN and on the horizon there is a whole new language - Perl 6.

There are many ressources on the web, blogs and presentations about why it is not bad and why it has a bad reputation it doesn't deserve - just have look at those to get an understanding.


答:
Over the past few years, I've discovered an iron rule:

Code always lives longer than you expect.

That one-shot throwaway thing you threw together in half an hour so that marketing could modify some text on a non-critical page designed for two weeks of production use will probably still be in use when you leave the company two years later. That little works-for-now deployment script you made will be used until the entire project dies. That little we'll-use-this-until-the-real-thing-is-finished replacement for the commercial and now defunct third-party ORM component you made may very well become the real thing itself.

Also, clean code does not take longer to write. It does if you write a truckload of quick-and-dirty code first and then clean it up, but if you start out clean and keep it clean along the way, it is often even faster.

A really good musician once told me: "Always play the best you can. Even when you're doing some warm-ups in your hotel room, give it all you have. You never know who's in the room next door listening."

Title: How clean should new code be?


问:
Is the Product Owner also a developer on your team?
I'm confused about the PO's responsibility here. I was a developer on a Game Feature Team, but  also a PO. The daily work of the developer is almost full time, so I have to work over time to take care my PO duty, and the responsibility of PO seems to be against developer's thoughts.

As a PO, I will chose more features next sprint. Otherwise, I will tell myself not to do so, because I'm a team member to develop those features. This situation makes me confused, so I want to hear some ideas from you guys.

I'm a new to Scrum and Game Dev (about 1 and half year), and also new to here and English.

答:
Interesting that I'm giving advice to a guy named Charlie, (My name is Charles) but I do have some experience in dual-roleing as a dev/PM, and in my experience, it's VERY easy to get too wrapped up in one role or the other.

If you're able to keep on top of both roles, by all means do so, but budget your time, and keep context switching between those two roles to an absolute minimum, especially within a single day.

Ideally, I would recommend that you avoid mixing these roles, as they are, as you have noticed, quite a bit in conflict with each other.

OwnerDisplayName: Charlie


答:
Providing your use case isn't dependent on speed you can use things like .net remoting and XML services to allow different platforms/languages/environments to talk to each other (this is the approach used by the Robot Framework RemoteLibrary for example).

Another option is to have some common data store behind both languages (typically a database).


问:
Is it possible for an amateur to become a good programmer?
A professional full-time programmer can do a great job by continuously learning from their work. How can an amateur programmer train to become a good programmer? </p>

<p>** If you like to play music or sing, you can do it because it is your hobby and you are interested, and you can become a good singer or music player. But you do not need to become a professional singer or do singing for a living. Is this also true for programmers ? Any amateur programmer who is famous?</p>

答:
The road to become good at programming is the same as for singing or playing music: practice, practice, practice. If you spend enough time regularly developing software for several years, chances are you will become good at it - be it inside or outside working hours.

Now, apart from spending more time practicing, there is another reason why professionals usually become better than amateurs in a certain sense (in music as well as in programming). If you are a professional, you have to do tasks which you don't necessarily like, but belong to the wider job of developing software (e.g. testing, discussions with customers, writing documentation, setting up dev/build environment, writing build scripts etc). And every now and then you are also pressed to step into unfamiliar areas, to learn new languages or platforms. As an amateur, you aren't forced to do anything you don't want to, which makes it likely that you stay within your comfort zone for most of your life. In other words, you can easily become limited to one or a few specific areas you are most fond of, and miss a lot of opportunities to learn and grow.

OTOH many professional developers fall into this as well, staying at the same company doing the same routine job hardly learning anything new for decades... So the key to become better is your attitude. If you keep learning, and consciously look for opportunities to move out of your comfort zone into new, unfamiliar territory, you will eventually outperform those swarms of slowly fossilizing "professionals". A good way to this may be contributing to some open source projects.

A recommended reading is The Pragmatic Programmer: From Journeyman to Master, with lots of great and very practical advice on how to keep becoming better.


答:
The key to becoming really good is working in a good team. Many amateurs work alone, so they only get that far. In a team, you learn from others, and you become disciplined because your peers will hit you with whatever comes handy otherwise.

For that reason, I propose you join a team, e.g. an open source project, or make a hobby project with some friends.

Title: Is it possible for an amateur to become a good programmer?

Body:
A professional full-time programmer can do a great job by continuously learning from their work. How can an amateur programmer train to become a good programmer? </p>

<p>** If you like to play music or sing, you can do it because it is your hobby and you are interested, and you can become a good singer or music player. But you do not need to become a professional singer or do singing for a living. Is this also true for programmers ? Any amateur programmer who is famous?</p>


答:
As an amateur programmer you have nowadays lots of possibilities to improve your skills. I did the following to improve my skills while studying software engineering.

Read books, e.g. UML distilled, The Pragmatic Programmer, Introduction to Algorithms.

Read websites like https://softwareengineering.stackexchange.com/. I have been doing this for the past few months while sitting in the metro / train. It certainly helps reading other peoples' questions and opinions.

Attend free lectures, courses or seminars. For instance you could attend Java User Groups. Sometimes there are also free seminars for students.

Subscribe to a software magazine.

Subscribe to interesting RSS feeds like Joel on Software, Google-Code-Blog, Martin Fowler.

Listen to podcasts while driving to work or school, e.g. SE-Radio.

Check out OpenCourseWare and do some of the university's practical assignments!

Of course you also need to apply your knowledge. Do this through an internship, a project with friends or study course. There are many ways to improve yourself, you just have be willing to invest your free time. Also, have fun learning something new!


答:
But for an amateur programmer, how can train to become a good programmer?

You become better by learning, which is part doing, part reflecting over what was done.

So basically, theres no difference between hobbyist and professional, but the 'pitfalls' are arranged a little different.

Amateur Pitfalls are, imho

the need to finish your project, no matter what, is not as strong when you're not professional. This can be a good thing, because you will not get that used to cut corners when it comes to quality, but finishing (at all! on time is even better) is a very important skill, which is harder to train as an amateur, because it's easy just to let a project die and start another one.

the need to communicate well is not as strong. On a professional project, there is a strong incentive to really understand the customers, even if they are completely unable to form just one coherent sentence of what the problem is they want you to solve. If you misunderstand them, or (the usual case) don't notice, that they dont talk about something you need to understand, it will become your problem, sooner or later. An amateur project can easily loose all potential users, due to not solving their problems, and be 'finished' in a technical way.

Professional Pitfalls are

there's often little motivation to get better. You're there 40h/week, no matter if you find the cure for cancer or just drink coffee in a way that looks productive. Learning is something you do mainly for yourself, and often, if you try to apply the things you learned, there are forces that work against that (conservative groupthink, hierarchies, even styleguides can be used as weapons against improvements). It takes a lot of love for the profession to not just give it up, hack down your hours, and look for alternate purposes in life.

there's often little to learn from. Yes, one CAN try to take everything as a challenge, but we have to be honest: after 1 Year of the Spaghetti code you aren't allow to refactor ("you're complicating it!") in a language you have more years of experience in than it will probably last, the only thing one learns is to build a tolerance against frustration and corporate politics.

If you play music, or singing, you can play it for interest, you can
  still become a good singer or music player, but not need to
  become a professional singer, or do singing for living.

You of course don't need to, but how many Musicians would turn down an opportunity to actually quit their job and make money with their music?

In IT, these opportunities are a little more probable than in Music, therefore i think, it's not that it is impossible to become a famous amateur, but oftentimes, the amateurs make their passion their job (with similar problems musicians have when they have to figure out their line between commerce and art)


问:
Does adding unit tests make sense for well-known legacy code?

I'm talking about unit tests in the TDD sense. (Not automated "integration", or what you like to call it tests.)

Legacy code as in: (C++) code without tests. (see: Michael Feathers' Working Effectively with Legacy Code)

But also legacy code as in: Code that our team has been working with for the last 10-5 years, so we very often have quite a good idea of where to put things to change something.

We do have unit tests in place (via Boost.Test) for some modules that came later or have been a "natural" fit for unit tests (common app specific containers, string-stuff, network helpers, etc.)

We do not yet have proper automated acceptance tests.

Now, recently I had the "pleasure" to implement 3 new user-facing features.

Each of those took me about 1-2 hours of getting up to speed with the code parts I needed to change, 1-2h hours to implement the (little) code I needed to change and another 1-2 hours to make sure the app ran correctly afterwards and did was it was supposed to do.

Now, I really added little code. (I think one method and a few call lines for each feature.)

Factoring out this code (via any of the methods suggested in WEwLC), so that a unit test would've make sense (and not been a complete tautology) would have easily taken another 2-4 hours, if not more. This would have added 50%-100% time to each feature, with no immediate benefit, as

I did not need the unit test to understand anything about the code

Manual testing is the same amount of work, as I still need to test if the code is correctly integrated into the rest of the app.

Granted, if, later on, "someone" came along and touched that code, he theoretically could have some benefit from that unit test. (Only theoretically, as that tested island of code would live in a ocean of untested code.)

So, "this time" I chose to not do the hard work of adding a unit test: The code changes to get that stuff under test would have been significantly more complex than the code changes to get the feature correctly (and cleanly) implemented.

Is this something typical for strongly coupled legacy code? Am I lazy / do we set the wrong priorities as a team? Or am I prudent, only testing stuff where the overhead isn't too high?

答:
The gain of unit tests in TDD sense is to get something that stands by itself, without needing oral tradition built over years by a stable team.

It is a big luck that the same team has been on the same project for so many time. But this will eventually change. People get sick, bored or promoted. They move, retire or die. New ones come with new ideas and the urge to refactor everything the way they learned at school. Companies get sold and bought. Management policies change.

If you want that your project survive, you have to prepare it for changes.


答:
Writing unit tests is future proofing your code.  If the code base does not have tests, then you should add new tests for all new features because it makes that bit of the code just that little more robust.

I find that adding tests, even in legacy code, is beneficial in the medium to long run. If your company does not care about the medium to long term, I would look for another company.  In additions, I do not think that it takes longer to test manually than it take to write a set unit test.  If it does, then you need to practice code kata focused on writing tests.

Title: Does adding unit tests make sense for well-known legacy code?

Body:
I'm talking about unit tests in the TDD sense. (Not automated "integration", or what you like to call it tests.)

Legacy code as in: (C++) code without tests. (see: Michael Feathers' Working Effectively with Legacy Code)

But also legacy code as in: Code that our team has been working with for the last 10-5 years, so we very often have quite a good idea of where to put things to change something.

We do have unit tests in place (via Boost.Test) for some modules that came later or have been a "natural" fit for unit tests (common app specific containers, string-stuff, network helpers, etc.)

We do not yet have proper automated acceptance tests.

Now, recently I had the "pleasure" to implement 3 new user-facing features.

Each of those took me about 1-2 hours of getting up to speed with the code parts I needed to change, 1-2h hours to implement the (little) code I needed to change and another 1-2 hours to make sure the app ran correctly afterwards and did was it was supposed to do.

Now, I really added little code. (I think one method and a few call lines for each feature.)

Factoring out this code (via any of the methods suggested in WEwLC), so that a unit test would've make sense (and not been a complete tautology) would have easily taken another 2-4 hours, if not more. This would have added 50%-100% time to each feature, with no immediate benefit, as

I did not need the unit test to understand anything about the code

Manual testing is the same amount of work, as I still need to test if the code is correctly integrated into the rest of the app.

Granted, if, later on, "someone" came along and touched that code, he theoretically could have some benefit from that unit test. (Only theoretically, as that tested island of code would live in a ocean of untested code.)

So, "this time" I chose to not do the hard work of adding a unit test: The code changes to get that stuff under test would have been significantly more complex than the code changes to get the feature correctly (and cleanly) implemented.

Is this something typical for strongly coupled legacy code? Am I lazy / do we set the wrong priorities as a team? Or am I prudent, only testing stuff where the overhead isn't too high?


答:
I'm afraid there are more possibilities for learning for the amateurs than for the full time corporate drones. As an amateur you're not confined with any given technology, environment, design and development methodology. You can do whatever you find useful for your personal development. As a full time developer you'd likely be working on a same product for years, following the same routine, limited by the same corporate guidelines. For most of us it is nothing but a stagnation. A little can be learned from a corporate environment, once you're familiar with the common basics.

That's the reason why many full time developers are also amateurs, they keep coding after work, they're playing with their own toy projects - it is a bit of freedom necessary for a growth.


答:
Certainly best practices dictate you should unit test any code you change. Real world coding however involves a lot of compromises, time and materials are finite.

What you need to do is evaluate the cost in real terms of fixing bugs and making modifications without unit tests. You then can asses against the investment in creating those tests. Unit tests greatly reduce the cost of future work but come at a price now.

Bottom line is if your system is rarely changed then it may not be worth writing unit tests but if it is subject to regular changes then it will be worth it.


答:
I don't what it defines a good programmer. But learning something their own and working with a group of people is something different. The passionate amateur programmers really in to learning new things and hacking. There were they find things more interesting. But working with a group of people is slightly a disciplined act where you collaborate, communicate, share/gain information from the experts in that area.

But gaining knowledge is only matters of passion. There are people who spent nights to learn stuffs themselves and finally end up bringing in something new to the world like Bill G Mark Zuck etc. Can't easily compare. but if you want to be a better Software engineer (I won't call Programmer) join in  a company or work for some good products which is used by others.

Finally read a lot to improve your skills, attitude, industry updates, develop a taste and go with a passion. Things will easily follow you!


答:
You have to be pragmatic about these situations. Everything has to have a business value, but the business has to trust you to judge what the value of technical work is. Yes, there is always a benefit to having unit tests, but is that benefit great enough to justify the time spent?

I would argue always on new code but, on legacy code, you have to make a judgement call.

Are you in this area of code often? Then there's a case for continual improvement. Are you making a significant change? Then there's a case that it is already new code. But if you're making a one-line code in a complex area that will probably not be touched again for a year, of course the cost (not to mention risk) of reengineering is too great. Just slap your one line of code in there and go take a shower quick.

Rule of thumb: Always think to yourself, "Do I believe that the business benefits more from this technical work that I feel I should do than the job they asked for which is going to be delayed as a result?"


答:
All of these little rational decisions to not create tests are building up a crippling technical debt that will come back to haunt you when somebody leaves & a new hire has to come in & get up to speed.

Yes, it might have cost another 2-3 hours to write the unit tests but if the code gets sent back from testing you'll have to manually test everything again, and document your testing, again - you do that don't you? Otherwise how does anyone know what you tested and what values you used?

Unit tests document the expected behaviour of the code the test data used to check the functionality and gives new coders reasonable confidence that they haven't broken something when making changes.

It costs a couple of hours today more than manual testing but then you are testing every time you do any change saving hours over the life of the code.

However, if you know that the code will be retired in a couple of years all I've said changes because you won't finish putting tests in the code & it'll never pay back.


问:
Will real world applications ever need a 128-bit flat address space?
This is a bit "one megabyte should be enough for anyone", but...

A 64-bit flat address space allows up to 4.3ish billion times more space than a 32-bit address space. That's 17,179,869,184 GiB.

Obviously, the transition from 8 bits to 16 bits was pretty quick (I'm viewing things in a teen-during-the-80s way, ignoring all those mainframes and minis because they couldn't run a port of Elite). The transition from 16 bits to 32 bits took a bit longer, and 32 bits actually lasted quite a while.

Now we have 64 bits, would it be stupid to say "17,179,869,184 GiB should be enough for anyone"?

This is a programmers question because I really have the programming viewpoint in mind. Even if a computer some day has a seemingly infinite amount of working memory, that doesn't mean that applications will need to see a seemingly infinite flat address space.

Basically, can we programmers breath a sigh of relief and say "well, whatever integers or floats may do, at least I don't have to worry about my pointers growing any more?".

答:
Just “thinking out loud” here, but it just occurred to me that one could do interesting semantic things with the remaining 64 bits on a, let’s say,  128 bit computer. Cf. the way IP works.

I am sure people could come up with fun uses for something like this. :) Anybody know what the PS3 uses its 128 bit addresses for? Surely you wouldn’t waste all that extra memory (and I am talking about just the memory for the actual addresses, not what those addresses point to). Addresses as data. You could even encode a branch in the address itself... i.e., 0x[ifAddress][elseAddress] Multi-core systems might benefit from this type of segmentation too. And... And...


问:
Should the creation of an object implicitly or explicitly create a file?
I'm creating an object whose sole purpose is to read in a file of one format and create another of a different format.

Is it best to create the output file implicitly during object initialization or to have a public method that gives the user the choice when this file will be created?

答:
Explicitly.  </p>

<p>You want to make sure that you do not rely on clever side effect rules that may either break in future releases or on uncommon architectures.  Of course, you should have a default file that the user can overwrite should they choose to.  </p>

Body:
Explicitly.

You want to make sure that you do not rely on clever side effect rules that may either break in future releases or on uncommon architectures.  Of course, you should have a default file that the user can overwrite should they choose to.


问:
Team member missing? Glue between data producers and data consumers
We're in the business of automated trading and our team consists of two bigger groups, I call them data producers and data consumers.

The producers' primary task is to maintain a chain of smaller tools that push some real-time data through an indicator system and out comes an order.  All the data that was needed or produced is logged into files, one file per tool per run.

The data consumers on the other hand, used to backtests and captured in their backoffice world, want to fragments of the data produced in the different runs, polished to their needs, more specifically one big post-processed chunk of data per day.

Now the problem that has split our team into two well-distinguishable sides is that the data producers consider it their responsibility to provide comprehensive data without any loss of information and want the consumers to cherry-pick whatever they need in a pre-processing step.

The consumers on the other hand want to see live trading as a black-box, to them it shouldn't be different to the backtest which means the data producers in their eyes lack a crucial post-processing step without which they can't start their task.

Now clearly there has to be some glue between the two teams, my question is whose task is it?  Or is there to be a third group in the middle that provides the glue?  What does the theory say about this (can we apply the producer/consumer pattern to `real life')?

And just to make the problem a real one: The data producers consider it ugly to boil down the data into consumable chunks, mainly because the consumers' side keeps changing their requirements.
The consumers on the other hand are not skilled enough to do the proposed cherry-picking.

答:
I think it's appropriate to have someone who has a view into what each team is doing, and can identify potential problems, opportunities, redundant work and so on and make recommendations to improve things. It'd be that person's responsibility, from the technical side, to determine whether what the different groups are working on can fit well together and will solve the business problems. It would not (necessarily) be that person's responsibility to decide whether the problems being solved are the right ones, though. Call that person a technical officer, an architect, a principal engineer, or whatever.

I don't think you'd want a third "interface group", which would essentially have the responsibility to show whether the two other groups were doing compatible work, but would probably lack the authority to make changes to what each group was up to. Because now you have three problems: the two official interfaces that will spring up between the first-second and second-third groups and the unofficial one that arises to work around the bureaucracy inherent in communicating between the first-third groups.


答:
The value of unit tests does not only lie in testing a new feature when that is developed. The benefit of unit tests is gained mostly in the future.

Yes, you may have to spend what seems like an inordinate amount of time to make your legacy code testable.

But if you don't, you will, or certainly should, spend many, many, many more hours testing the feature. Not just on its initial development, but with every new version of your software. Without unit tests and other automated testing, you do not have any other option but to spend many hours of manual testing to ensure that your feature was not inadvertently broken, even when that feature itself was not changed.

ContentLicense: CC BY-SA 4.0


答:
If you're bent on doing it in the class, create it during initialization.  Delaying that step does two bad things:  First, it adds an extra, explicit step for the caller, who wouldn't have created the object in the first place unless they intended to use it to produce output.  Second, it adds at least two points where code in the class has to make a decision about whether or not the file is open and handle that condition: once when you go to write output and once during destruction when you go to close it.  The former means you have to make that check during every write, which could be wasteful if you're doing a lot of them.

Personally, I would do neither and opt for making the caller pass pre-opened file handles to the constructor.  Creating the file inside the class precludes giving the callers the options to do things like setting permissions or, if writing to a device, doing device-specific initialization.  If you want to have a version of your FooConverter class that operates on files and does the creation grunt work, wrap it in a FooFileConverter.

Title: Should the creation of an object implicitly or explicitly create a file?

Body:
I'm creating an object whose sole purpose is to read in a file of one format and create another of a different format.

Is it best to create the output file implicitly during object initialization or to have a public method that gives the user the choice when this file will be created?


答:
If you like to play music or sing, you can do it because it is your
  hobby and you are interested, and you can become a good singer or
  music player. But you do not need to become a professional singer or
  do singing for a living. Is this also true for programmers ? Any
  amateur programmer who is famous?

Not at all. It's software engineering. It's not based on "natural talent". Being great programmer is based on years of education and years of experience. You only get that working on real projects.


问:
How to account for a bug fixing iteration?
We have implemented Scrum quite successfully for the past 5 months. Though, we are 3 weeks away from PROD without ever doing any end-to-end integration test. OUCH! I need help. Without tackling the causes of this (at THIS point), we need now to plan the current iteration, which consists of minor improvements and MANY still unknown bug fixes. How do you account for this scenario? How do you plan your iteration to fix bugs yet to be found?

答:
You need to define a set of "release" criteria. These could include:

Mean time between failure

Number of defects found per day

Severity of defects found per day

Number of defects outstanding

etc.

Then at the end of each iteration where you have some people testing (either manually or by writing automated tests) and others fixing check to see if you've met your criteria. If you have then release, if not then go for another iteration.

There should be the possibility of an override on this as well as often the raw numbers don't present a realistic picture of the application. You may have a couple of really serious defects, but they only manifest under rare conditions which you can live with in the short term.


答:
The way I see it you split a larger project into two chunks. The only sensible thing to split projects into are modules. Modules have and interface and an implementation. A module is good, if the interface is clear and leaks no information about the implementation. The way it seems now, the "producer team" did not create a module, only an unusable set of tools.

OTOH you can't expect their module to provide data in a structure perfectly suitable for every scenario. The needs of your clients may change and that actually shouldn't be affecting their work.

Depending on how much work needs to be done to transform a well designed producer module's output to a suitable consumer module input you then might need to create another module, who's interface depends on your needs and who's implementation depends on the interface of the producer module (and its own interface of course). If the producer interface is any good and the consumer requirements are the least bit reasonable, implementing such a module is trivial and is something you can demand of the producer team, assuming this really has an organizational benefit.

Title: Team member missing? Glue between data producers and data consumers

Body:
We're in the business of automated trading and our team consists of two bigger groups, I call them data producers and data consumers.

The producers' primary task is to maintain a chain of smaller tools that push some real-time data through an indicator system and out comes an order.  All the data that was needed or produced is logged into files, one file per tool per run.

The data consumers on the other hand, used to backtests and captured in their backoffice world, want to fragments of the data produced in the different runs, polished to their needs, more specifically one big post-processed chunk of data per day.

Now the problem that has split our team into two well-distinguishable sides is that the data producers consider it their responsibility to provide comprehensive data without any loss of information and want the consumers to cherry-pick whatever they need in a pre-processing step.

The consumers on the other hand want to see live trading as a black-box, to them it shouldn't be different to the backtest which means the data producers in their eyes lack a crucial post-processing step without which they can't start their task.

Now clearly there has to be some glue between the two teams, my question is whose task is it?  Or is there to be a third group in the middle that provides the glue?  What does the theory say about this (can we apply the producer/consumer pattern to `real life')?

And just to make the problem a real one: The data producers consider it ugly to boil down the data into consumable chunks, mainly because the consumers' side keeps changing their requirements.
The consumers on the other hand are not skilled enough to do the proposed cherry-picking.


答: I'm not saying I recommend this approach, but in the spirit of completeness, you could use COM to invoke Python from .NET or visa versa.  I have never used COM with Python but apparently it is possible.</p>


答:
If you are working in a language that supports it, I'd provide a Save method that takes a Stream. That way, the user can save the data whereever he or she wants.

It takes 20 seconds longer to write than saving just to a file, but it is easily understood by a programmer, and at the calling site it is very clear what actually happens.

The way you described it (an object that reads input, and outputs to another file) otherwise  seems weird. What is the purpose of constructing an object that does everything during construction?

Would you call it this way?

```<code>var stuff = DoStuff();
new SaveFileWeirdClass(stuff);
return;
</code>```

For any reasonable implementation of SaveFileWeirdClass I would expect no side effects from just creating it. Reading a file - fine. Creating a file? No.

To me it seems clearer this way:

```<code>var stuff = new StuffReader(); //Better name needed...
string filePath = this.whatever;

using(Stream stream = new FileStream(filePath))
    stuff.Save(stream);
</code>```

Body:
If you are working in a language that supports it, I'd provide a Save method that takes a Stream. That way, the user can save the data whereever he or she wants.

It takes 20 seconds longer to write than saving just to a file, but it is easily understood by a programmer, and at the calling site it is very clear what actually happens.

The way you described it (an object that reads input, and outputs to another file) otherwise  seems weird. What is the purpose of constructing an object that does everything during construction?

Would you call it this way?

var stuff = DoStuff();
new SaveFileWeirdClass(stuff);
return;

For any reasonable implementation of SaveFileWeirdClass I would expect no side effects from just creating it. Reading a file - fine. Creating a file? No.

To me it seems clearer this way:

var stuff = new StuffReader(); //Better name needed...
string filePath = this.whatever;

using(Stream stream = new FileStream(filePath))
    stuff.Save(stream);


答: On job interviews I've been to (on employer's side), I've always asked for stuff the interviewee has been programming as an amateur (except school assignments) - having done that is a sure sign of genuine interest in the field and having passion to learn on one's own. It's not only possible, it's almost a requirement for becoming good.


答:
You're asking a very specific question based on a very specific project and set up but it actually points to a generic answer that applies to all projects:

It's whoever it's agreed to be by the people involved.

There is no one right team structure, even for a specific situation. It will depend on the people involved, their skills, the time they can commit, the business and so on and so on.

Which means that the only approach you can take is to make sure that when you set up a project responsibilities are agreed within the team and that, as in this case, if you miss something, it gets picked up and assigned as soon as it's identified.

The first thing to try would be to get the two teams to talk it through and agree something. Ideally they would and they'd just take it to the PM and say "this is what we think" and he or she would say "great".

If that doesn't happen (for instance because they don't agree), then you need to take it to the PM and / or whoever determined that you will have these two groups. That decision was presumably taken based on some criteria or other and that will usually be a good starting point.

But there's nothing authoritative that's going to tell you how this situation should work, certainly not a group of people on the internet who understand none of the subtleties of the situation and have nothing at stake...


答:
How to account for a bug fixing iteration? How do you plan your
  iteration to fix bugs yet to be found?

Regarding a "bug fixing iteration".  Bugs found should be treated no differently from stories.    Work with the team to estimate the effort (story points) to fix each bug and work with the product owner/customer to decide if the bug should go into the next iteration.

Regarding "bugs yet to be found".  Preferably, the team is finding and fixing issues each iteration.  If your not, then discuss this in your next retrospective.  If the product quality is so low that release is not possible, then immediately move your best "bug finders" to finding bugs (not fixing).  If quality is high enough to provide a beta release to select users - do it.  If you can't, then at minimum provide live user demos discussing weak areas you recommend needs improvement.

Body: We have implemented Scrum quite successfully for the past 5 months. Though, we are 3 weeks away from PROD without ever doing any end-to-end integration test. OUCH! I need help. Without tackling the causes of this (at THIS point), we need now to plan the current iteration, which consists of minor improvements and MANY still unknown bug fixes. How do you account for this scenario? How do you plan your iteration to fix bugs yet to be found?


问:
How do I create my own programming language and a compiler for it
I am thorough with programming and have come across languages including BASIC, FORTRAN, COBOL, LISP, LOGO, Java, C++, C, MATLAB, Mathematica, Python, Ruby, Perl, JavaScript, Assembly and so on. I can't understand how people create programming languages and devise compilers for it. I also couldn't understand how people create OS like Windows, Mac, UNIX, DOS and so on. The other thing that is mysterious to me is how people create libraries like OpenGL, OpenCL, OpenCV, Cocoa, MFC and so on. The last thing I am unable to figure out is how scientists devise an assembly language and an assembler for a microprocessor. I would really like to learn all of these stuff and I am 15 years old. I always wanted to be a computer scientist someone like Babbage, Turing, Shannon, or Dennis Ritchie.

I have already read Aho's Compiler Design and Tanenbaum's OS concepts book and they all only discuss concepts and code in a high level. They don't go into the details and nuances and how to devise a compiler or operating system. I want a concrete understanding so that I can create one myself and not just an understanding of what a thread, semaphore, process, or parsing is. I asked my brother about all this. He is a SB student in EECS at MIT and hasn't got a clue of how to actually create all these stuff in the real world. All he knows is just an understanding of Compiler Design and OS concepts like the ones that you guys have mentioned (i.e. like Thread, Synchronization, Concurrency, memory management, Lexical Analysis, Intermediate code generation and so on)

答:
ANTLR is a good starting point. It's a language generating framework, similar to Lex and Yacc. There's a gui called ANTLRWorks that simplifies the process.

In the .NET world there the Dynamic Language Runtime which can be used to generate code in the .NET world. I've written an expression language called Zentrum that generates code using the DLR. It will show you how to parse and execute statically and dynamically typed expressions.

OwnerDisplayName: Dave


答:
As an amateur you have more options to seek out better practices than many professionals.  Professionals are often under pressure to "just get it done".

I haven't seen any courses like I learned programming from, but I learned from some short (1-3 hour) free courses presented by the University I was attending.  They were intended to enable Business people to understand code being written for them.  The courses presented very well written code (comments included) that solved a common real life problem.  The code was then reviewed with an explanation of the language features and why they were used the way they where.  None of the full language courses I have seen result in code anywhere near the quality of what I learned from that course.   It was a couple of years before I switched to studying Computer Science.

The Internet and library provide lots of resources and examples.  I find many of the examples aren't very good for anything but getting it done.  When looking at examples, look at the code first.  Can you understand it purpose and structure without the explanation?  If so, you may have found a good example.

Some key practices you should should learn and apply:

DRY (Don't Repeat Yourself).

DRO (Don't Repeat Other); Use the standard language libraries, use other libraries.

Keep code simple.  Elegant code tends to be harder to maintain.   Even worse, optimizers often produce slower machine code, than for the simpler code.

Modules should have only one purpose.  (It is better if that purpose is either to do work or make decisions.)

Use good names.  Don't use short names to avoid typing, use an IDE with auto-complete instead.  Understand the naming conventions of your language.

Don't optimize your code.  Wait until you can measure its performance and know that optimizing it will have a noticeable effect.

Keep learning.  Learn to identify resources which will provide useful information you can use now.


答:
Scrum or not, bugfixing is basically impossible to predict. The best I believe you can do is:

Start testing immediately, without initial estimate when it will be done.

When you discover each bug, do initial analysis to the point you can estimate it.

Estimate the bug and decide whether it has to be fixed and whether it has to be fixed for the initial relese.

If it has to be fixed, add it to the iteration.

Plot a burn-down chart. At some point it will start to decrease, meaning you are no longer finding bugs faster than you manage to fix them. At that point you will be able to give out rough estimation (and progressively more precise) when the release can be made.

Than you should make sure next time you start testing early and fix bugs as you go. All sensible methodologies, agile or not, call for fixing known bugs before progressing with new features. Also you should account how much time was spent bugfixing each feature, so you can improve your estimate for implementing feature to debugged state in future.

The estimation and bugfixing are nicely covered by Joel Spolsky in Evidence Based Scheduling and Hard-assed Bug Fixin'. It's not Scrum-related, but I think it's general enough that much of it applies.

Title: How to account for a bug fixing iteration?


答:
Is it possible?  Yes.  However, the more time you spend programming the more time you have to get better at it.  Its been said it takes 10 years / 10 000 hours of deliberative practice to develop expertise at a technical skill.  That's not 10 000 hours of doing the same sort of coding in your comfort zone (e.g., writing simple jQuery code for different websites), but 10 000 hours of learning/reading about programming/reading source code/writing source code/learning other languages/working with others, etc.

If you are going to devote that level of time to it; you might as well get a job as programmer and drop the amateur status.  (Unless you are independently wealthy).


问:
Is it unnecessary to use Github (social coding) even if you are the only one working on a project?
I started using Github now that I'm working on a project with some guys. And I started to wonder if I should use it in my personal projects too. I'm not sure if this will help me in some way or if it is unnecesary? </p>

答:
There's a distinct difference between using GitHub and using {your favorite version control software}.

If you're working on a project, it should be under some kind of version control somewhere, preferably off your local machine, so it's stored in two places should something happen to one machine. Putting your code on a site like GitHub (or SourceForge or BitBucket or Google Code...) helps you maintain these backups and version control repositories, but you need to balance that with the licensing and visibility (an example being Google Code, which requires an open-source license).


答:
I use BitBucket for my personal projects but any other online source control can work for you.

This way I'm sure that I always have a backup of my projects. Plus, it's free so why wouldn't you use some form of Source Control?

Title: Is it unnecessary to use Github (social coding) even if you are the only one working on a project?

Body: I started using Github now that I'm working on a project with some guys. And I started to wonder if I should use it in my personal projects too. I'm not sure if this will help me in some way or if it is unnecesary? </p>


答: Are the data consumers the users the data producers are producing tools for? In this case, what they need is ther requireement, not what you would rather do.</p>


答:
To the question, "have any amateur programmers become famous?" The answer is "Yes, but most did not stay that way." The most famous example I can think of is Roy Fielding who did some of his most important work while (I believe) unpaid at University (amateur means un-paid by definition).

The trick to being of professional quality is having a mentor or set of mentors (such as a team in an open source project) and serious time dedication to the topic. As a formerly professional musician, my experience is that both of these are necessary to be good either as a professional or an amateur. Some can be learned by books, but without consistent external critique it becomes very difficult to get through bad habits acquired as a novice.

That said, in the case of the programmer, it is substantially easier to learn than that of the musician — it was my experience that as a musician it is much harder as a musician to see your pedagogical errors than it is to see code which just doesn't work. On the other hand, it also requires a substantially greater time investment to be a good developer.


答:
You don't necessarily need to use github. But I would definitely advise you use some sort of version control. Use git if you think you might want to use github in the future, which will make thing easier when you do.

Version control really helps you when you need to debug something or want to develop a feature in a different direction. If anything at all see it as a global undo feature in case something goes wrong ;)


答: Everyone is an amateur at everything at one point. If you want to become a good programmer and it's something you enjoy doing, you will. The key is programming on your own. School will teach you next to nothing. Most of your learning will be done on your own and at work. If you want to be good, go be good. </p>


问:
Is it bad practice for services to share a database in SOA?
I have recently been reading Hohpe and Woolf's Enterprise Integration Patterns, some of Thomas Erl's books on SOA and watching various videos and podcasts by Udi Dahan et al. on CQRS and Event Driven systems.

Systems in my place of work suffer from high coupling. Although each system theoretically has its own database, there is a lot of joining between them. In practice this means there is one huge database that all systems use. For example, there is one table of customer data.

Much of what I've read seems to suggest denormalising data so that each system uses only its database, and any updates to one system are propagated to all the others using messaging.

I thought this was one of the ways of enforcing the boundaries in SOA - each service should have its own database, but then I read this:

https://stackoverflow.com/questions/4019902/soa-joining-data-across-multiple-services

and it suggests this is the wrong thing to do.

Segregating the databases does seem like a good way of decoupling systems, but now I'm a bit confused. Is this a good route to take? Is it ever recommended that you should segregate a database on, say an SOA service, an DDD Bounded context, an application, etc?

答:
Decoupling only works if there really is separation.  Consider if you have an ordering system:

Table: CUSTOMER

Table: ORDER

If that's all you've got, there's no reason to decouple them.  On the other hand, if you have this:

Table: CUSTOMER

Table: ORDER

Table: CUSTOMER_NEWSLETTER

Then you could argue that ORDER and CUSTOMER_NEWSLETTER are part of two totally separate modules (ordering and marketing).  Perhaps it makes sense to move these into separate databases (one for each table), and have both modules share access to the common CUSTOMER table in its own database.

By doing that you're simplifying each module, but you're increasing the complexity of your data layer.  As your application grows larger and larger, I can see an advantage to separating.  There will be more and more "data islands" that really have no relation to each other.  However, there will always be some data that cross-cuts all modules.

The decision to put them in different physical databases would typically be based around real-world constraints like frequency of backups, security restrictions, replication to different geographic locations, etc.  I wouldn't separate tables into different physical databases just because of separating concerns. That can be handled more simply with different schemas or views.


问:
Help on clarification of a formal statement concerning algorithms running time
I am reading the following in a book on algorithms (Cormen's to be specific):

That is, we are concerned with how the running time of an algorithm
  increases with the size of the input in the limit, as the size of the
  input increases without bound.

I can not understand what is the meaning of the phrase:  with the size of the input in the limit.

What is the limit refering about?

UPDATE:

Please note that at this point in the book (early fundamentals of chapter 2) there has been no formal definition or mention of Big O or other asymptotic notation except a vague reference on Theta notation

Any help?

答:
Look at the formal definition of Big O notation to see a limit defined within the notation there.  While Big O is specifically about worst case complexity there are other notations for average case or best case.

Usually the idea is to get an upper bound of how bad does the algorithm run.  Is the complexity logarithmic, linear, quadratic, or exponential?  There are various examples one can give for some of those as a binary search can have logarithmic complexity as one is reducing half the options with each search assuming the initial set of data is sorted.  Quadratic would be various poor sorting algorithms like Bubble Sort.

An alternative view here is to note that "the size of the input increases without bound" is generally a way of describing a limit as a variable tends to infinity.  Limits to Infinity would be an example discussing f(x) = 1/x where as x grows without bound, the function value will approach zero.  The key is to imagine the running time of the algorithm as a function depending on the size of the input and as one changes that input, how quickly is the function growing.  Is it a straight line or a curve?  How steep is the slope at any point?  That is kind of the point behind the idea here.


答: It means that as the size of the input increases infinitely, what is the running time in relation to the input. Big O can be used to measure any factor, including memory, but is usually time.</p>

Title: Help on clarification of a formal statement concerning algorithms running time

Body:
I am reading the following in a book on algorithms (Cormen's to be specific):

That is, we are concerned with how the running time of an algorithm
  increases with the size of the input in the limit, as the size of the
  input increases without bound.

I can not understand what is the meaning of the phrase:  with the size of the input in the limit.

What is the limit refering about?

UPDATE:

Please note that at this point in the book (early fundamentals of chapter 2) there has been no formal definition or mention of Big O or other asymptotic notation except a vague reference on Theta notation

Any help?


答:
This doesn't sound much like a programming problem.  Rather it sounds more like a teamwork/business/management problem.

If the two groups already had a mindset that they were in the same team, working together to make the business succeed, this problem may have already solved itself.  At the least, they could bring any time/personnel constraints to the appropriate higher-ups.  Then, an appropriate decision could be made, with all 3 groups working with the same goal - here's a problem that needs solving so our business can succeed.

It sounds like you're dealing with a situation where neither team wants to do the work.  Generally that's a bad sign for the business' health.


答:
Where I work we have an ESB to which 6 different applications (or should I say "endpoints") are connected. Those 6 applications work with 3 different Oracle schemas on 2 database instances. Some of these applications coexist in the same schema not because they are related but because our database infrastructure is managed by an external provider and obtaining a new schema just takes forever (also, we don't have DBA access of course)... It really takes so long that at one point we thought of reusing an existing schema "temporarily" to be able to continue development. To enforce "separation" of data, table names are prefixed, for example "CST_" for customer. Also, we have to work with a schema that for some valid reasons we cannot absolute change... It's strange I know. Of course, as it always happens, "temporarily" has changed into "temporar-namently" if you know what I mean ;-)

Our different applications connect to their respective database schema and work with their own PL/SQL packages and we absolutely forbid ourselves to interact directly with tables/data that is outside our application domain.

When one of the application connected to the ESB needs information outside from its domain, it calls the related service on the ESB to obtain the data, even if that information is in fact in the same schema, requiring in theory just a little join statement in one of the SQL requests.

We do that in order to be able to split our application domain into different schemas/databases, and in order for the services on the ESB to still work properly when it happens (it's Christmas soon, we're corssing fingers)

Now, this may look strange and awful from the outside but there are reasons to that and I just wanted to share this concrete experience to show you that one or more databases is not that important. Wait, it is !, for many reasons (+1 for Scott Whitlock, see last paragraph about backup and such that mya lead you into trouble) But it is equally important I think to have your SOA services being properly designed, at least that is my opinion, and I'm not a DBA. Ultimately, all your databases belong to your "enterprise datawarehouse", right?

Finally, I won't rephrase Scott Whitlock's last paragraph, particularly this

I wouldn't separate tables into different physical databases just because of separating concerns.

is really super important. Don't do it if there is no reason.

Title: Is it bad practice for services to share a database in SOA?

Body:
I have recently been reading Hohpe and Woolf's Enterprise Integration Patterns, some of Thomas Erl's books on SOA and watching various videos and podcasts by Udi Dahan et al. on CQRS and Event Driven systems.

Systems in my place of work suffer from high coupling. Although each system theoretically has its own database, there is a lot of joining between them. In practice this means there is one huge database that all systems use. For example, there is one table of customer data.

Much of what I've read seems to suggest denormalising data so that each system uses only its database, and any updates to one system are propagated to all the others using messaging.

I thought this was one of the ways of enforcing the boundaries in SOA - each service should have its own database, but then I read this:

https://stackoverflow.com/questions/4019902/soa-joining-data-across-multiple-services

and it suggests this is the wrong thing to do.

Segregating the databases does seem like a good way of decoupling systems, but now I'm a bit confused. Is this a good route to take? Is it ever recommended that you should segregate a database on, say an SOA service, an DDD Bounded context, an application, etc?


问:
In what situations is it a bad idea to use open source code for a corporate project?
Are there any situations where it may not be a good idea to use the code of an open source project, even if your company might allow you to do so?

Some cases that I think might be valid include:

The code may be implemented in a different languages.

It is not portable

It may need some other close-source libraries

What might be some other reasons?

答:
The biggest thing I find with open source is support.

Is the open source project active?  If the project has not been updated in some period of time and there is no activity in forums or the community, you may not be able to get a bug fixed.

Is there paid support?  If it is written in a language you don't know or you don't have strong expertise on your team, you may really need paid support to get something fixed.

Depending on your company there may a security review required and if there are issues, you may not be able to get them fixed.


答: Decoupling databases and keeping the data consistent between them is an expert level task. It is very easy to get wrong and end up with the problems of duplicates etc, that the current system is designed to avoid. Frankly, taking a working system and doing this is pretty  much a guarantee of introducing new bugs for no real value to the users. </p>


问:
How is C different from C++?
Many people have said that C++ is a completely different language than C, but Bjarne himself has said that C++ is a language that is extended from C hence that is where the ++ comes from. So why does everybody keep saying that C and C++ are completely different languages? In what way is C different from C++ other than the extended features in C++?

答:
While C++ can be a super set of C in syntactic terms - i.e. any construct of C program can be compiled by C++ compiler.

However, you almost never write a C++ programs the way you would have done with C program. The list can be endless or may be someone should just do more research to put it as exhaustive reports. However, i am putting few pointers that make the key differences.

The point of the current post is that C++ has following features that a good C++ programmers must use as programming best practices even though C equivalent are possible to compile.

How should it be done in C++ over C

Classes & Inheritance.
That's most important differences that allows systematic object orientation that makes programming expression very powerful. I guess - this point needs no better explanation. If you are in C++ - almost always, you are better of making use of classes.

Privatization -
Classes, and even structures have what is private members. This makes encapsulation of a class possible. The equivalent in C is by way of typecasting the object as void * to application so that application doesn't have access to internal variables. However, in C++ you can have elements with public as well as private classes.

Pass by reference.
C++ allows modification based on reference, for which passing pointers is required. Pass-by-reference keeps code very clean and more so safer against pointer hazards. You an as well pass C style pointer and that works - but if you are in C++ you are better-off as long as

new & delete vs. malloc and free.
The new() and delete() statements not only allocates and de-allocate memory, but also allow code to execute as part of destruct-er to be called in a chain.
If you are using C++ - it is actually BAD to use malloc and free.

IO types and operator overloading
Operator overloading make code readable or more intuitive if done well. Same for << and >> io operators. The C way of doing this would be to use function pointers - but it is messy and only for advance programmers.

Using "string".
The char * from C works everywhere. So C and C++ is pretty much same. However, if you are in C++ - it is always much better (and safer) to use String classes which saves you from the dangers of arrays over running which are almost every things.

Features I would still not be fan of in C++
1. Templates -
While i don't use heavy templates in many codes - it can turn out to be very powerful for libraries. There is almost no equivalent of it in C. But on a normal day - specially if you are doing mathematically missing.

Smart pointers -
Yes, they are very smart! And like most smart things - they start out good and become messy later! I don't quite like to use

Things that i like about C and miss in C++

Polymorphic algorithms by using function pointers.
In C, when you are running complex algorithms - some times you can use set of function pointers. This makes true polymorphism in a powerful way. When you are in C++ you CAN use function pointers - but that is bad. You should be only using methods - else be prepared to get messy. The only form of polymorphism in C++ classes is function and operator overloading but that is quite limiting.

Simple threads.
When you create threads were pthreads - it is quite simple and manageable. It becomes when you need to create threads which are supposed to be "private" to the classes (so that they have access to private members). There is boost type of frameworks - but nothing in basic C++.

Dipan.

Title: How is C different from C++?


问:
Which CS courses are a "must" for a web developer
My goal is to learn how to program a website with Python/Django in the next year. From what I've understood, I also have to learn HTML, CSS, JavaScript.

I understand in order to build a website, I will need to find a co-founder whose skills far exceed mine. But still, the situation will be way different if I'm a person who's closer to his/her level and has dedicated a lot of time teaching himself than every other "I have an idea, just need a tech co-founder" type of guy.

I do plan to pursue a degree in computer science, but after finishing high school last May decided to take an year off, so I am free to learn programming in the next 10 months.

For now, I have the chance to attend some college courses in a top institution. Which ones are a must for a web developer so that I don't have any gaps in my understanding of programming and write "sophisticated code"?

EDIT:Thank you all for the help!From the courses suggested I may be able to attend some/none/all of OOP(with Java),Networks and Graphics,SE-Algorithms,Discrete Math for Comp.Scientists,Databases,Information Retrieval and Data Mining.Which of those are more important for Web development with Django?

I've read a lot of times people saying that self-taught programmers had gaps in their knowledge, didn't write clear code.This is why I'm asking which CS courses can fill those gaps? Not only in practical skills,but in mindset,way of thinking.

答:
May I suggest getting a bit beyond Django for a moment?  How well do you know HTTP?  How well do you know HTML?  Have you considered how you'll handle graphics in this website?  Do you know where you are going to host this web site?  What domain name it'll have?  There are probably a dozen more questions like this that I'd say are important things to consider here as Django alone isn't going to be a silver bullet.

Networks, databases, SE-Algorithms, OOP, and Discrete Math would all be areas I'd suggest as places to at least dip your toe and see what works and doesn't work for you.  You may be surprised at just how much other stuff you have to know and handle to get a site up and running would be my guess.  This is without considering things like social media integration as perhaps you'll want people to sign in with their Facebook or Twitter account rather than creating new accounts all over again.

I'm looking at this from the perspective that if your goal is to get a website you built using Python/Django up and running then there may well be things beyond just knowing Python/Django that can be useful here.  The "program a website" could mean 1,001 different things as there are many different possible uses for a site.  Do you plan on selling stuff from that site?  Is it just a sandbox so you can learn the basics of a website?  Is it for making your own Content Management System?  What will the site do?  Why would someone see the site?  Have you pondered any Search Engine Optimization parts to this?  To try to take everything but the Python/Django out of the equation here is a bit unrealistic, at least to my mind and so I'm wondering if you are seeing this from a broader perspective or are you wanting this to be where everything else is already handled so all you have to do is just one little thing.  While it is possible in theory, you may be more than a little surprised as to how much you are expecting from the other person in this situation.

Take a look at the last story in The High-Security Interview, The PHP Candidate, and Overqualified if you want an example of where while you have a good idea, you have to be careful about how far do you take it and how dogmatic are you wanting to be about this.


答:
given the real original meaning of the word (French amateur "lover of", from Old French and ultimately from Latin amatorem nom. amator, "lover" - Wikipedia), one would like to believe that a great number of professionals are also amateurs. If you don't love your craft, would you be practicing it?

Of course it's possible - if you love programming, you'll practice it and, over time, you will become good at it. (Maybe never great, given personal talents or lack thereof), but at least good