答:
Is it even possible to do TDD on embedded devices or when developing drivers or things like custom bootloader, etc.?

Some time ago I needed to write a first level bootloader for an ARM CPU.
Actually there is one from the guys who sell this CPU.
And we used a scheme where their bootloader boots our bootloader.
But this was slow, as we needed to flash two files into NOR flash instead of one,
we needed to build the size of our bootloader into the first bootloader,
and rebuild it every time when we changed our bootloader and so on.

So I decided to integrate functions of their bootloader into ours. Because it was commercial code, I had to make sure that all things worked as expected. So I modified QEMU to emulate IP blocks of that CPU (not all, only those that touch the bootloader), and add code to QEMU to "printf" all read/write to registers that control stuff like the PLL, UART, SRAM controller and so on. Then I upgraded our bootloader to support this CPU, and after that compared the output that give our bootloader and their on emulator, this helps me catch several bugs. It was written partly in ARM assembler, partly in C. Also after that modified QEMU helped me catch one bug, that I could not catch using JTAG and a real ARM CPU.

So even with C and assembler you can use tests.

Title: How do I do TDD on embedded devices?


问:
What does "GPL with classpath exception" mean in practice?
Oracle seems to license all their Java-related open source code under the GPL with a classpath exception. From what I understand, this seems to allow to combine these libraries with your own code into products that do not have to be covered by the GPL.

How does this work?

What are examples of how I can and cannot use these classes?

Why was this new license used as opposed to the LGPL, which seems to allow for pretty much the same things, but is better established and understood?

What are the differences to the LGPL?

答:
It looks like the "GPL with classpath exception" style licenses may be older than LGPL.

Perhaps the only reason anyone still uses it, is because GPL code cannot be migrated to LGPL code without written permission from everyone who ever contributed code.

OwnerDisplayName: Thilo

ContentLicense: CC BY-SA 4.0

OwnerDisplayName: Abhi Beckert

ContentLicense: CC BY-SA 3.0


问:
How do you share your craft with non programmers?
Sometimes I feel like a musician who can't play live shows. Programming is a pretty cool skill, and a very broad world, but a lot of it happens "off camera"- in your head, in your office, away from spectators.

You can of course talk about programming with other programmers, and there is peer programming, and you do get to create something that you can show to people, but when it comes to explaining to non programmers what is it that you do, or how was your day at work, it's sort of tricky.

How do you get the non programmers in your life to understand what is it that you do?

NOTE: this is not a repeat of Getting non-programmers to understand the development process, because that question was about managing client expectations.

答: Tell a story. Don't focus on what you do, but on how you feel when you do it, how you are passionate or bored about it, on relationships with your coworkers.</p>

ContentLicense: CC BY-SA 2.5


答:
GPL with classpath exception behaves like LGPL for most uses.

It does mean you need to be able to ship the source for the library on demand.
It does not mean you need to be able to ship your own source.
It happens mean you don't have to ship a way to replace the library if you statically link against it, but you cannot use a public key to prevent replacement.

Title: What does "GPL with classpath exception" mean in practice?

Body:
Oracle seems to license all their Java-related open source code under the GPL with a classpath exception. From what I understand, this seems to allow to combine these libraries with your own code into products that do not have to be covered by the GPL.

How does this work?

What are examples of how I can and cannot use these classes?

Why was this new license used as opposed to the LGPL, which seems to allow for pretty much the same things, but is better established and understood?

What are the differences to the LGPL?


问:
Programming language for simple program?
I am wondering about which programming languages people see fit to create a program idea that I had.  I am looking to create a fairly simple program whose main functions are adding to, managing, and searching through a database of people, all through a polished GUI.  It will be for use in the business world, so I think Windows would be the priority, but Mac and Linux support wouldn't be bad.  Also, eventually I would like to add the ability for an instance of one program on a computer to interact with other instances on the same network, mainly through the sharing of a database.

Most of my experience is in Java, but I don't particularly like the appearance of Java GUIs, so I'm looking for an alternative.  I noticed that a lot of people have suggested C++ or C# in similar posts, so what are some of the advantages/disadvantages of one or both if that is your suggestion.

Thanks for any help in advance.

答:
Well, some will hate me for this, but I say Perl. Perl's Tk module is great, easy to learn IMO, and takes less code than Java.

Also, Perl has a great DBI module which integrates well with Perl/Tk.

OwnerDisplayName: jamherst


答:
If you want to get the native system's UI and you do not like Java's implementations for native UIs or you want to go with C++ as your solution, I would suggest using the Qt framework. It offers a very "Java-esque" library for UI/Networking/Etc.

The advantages:

Easy (in my opinion) to use library.

Write once, compile anywhere.

Produces native binaries.

The disadvantages:

Requires Qt library DLLs (if you want a singular binary, static
linking can get big)

Uses proprietary, thus non C++, "code" (can complicate an external
build process)

Title: Programming language for simple program?

Body:
I am wondering about which programming languages people see fit to create a program idea that I had.  I am looking to create a fairly simple program whose main functions are adding to, managing, and searching through a database of people, all through a polished GUI.  It will be for use in the business world, so I think Windows would be the priority, but Mac and Linux support wouldn't be bad.  Also, eventually I would like to add the ability for an instance of one program on a computer to interact with other instances on the same network, mainly through the sharing of a database.

Most of my experience is in Java, but I don't particularly like the appearance of Java GUIs, so I'm looking for an alternative.  I noticed that a lot of people have suggested C++ or C# in similar posts, so what are some of the advantages/disadvantages of one or both if that is your suggestion.

Thanks for any help in advance.


问:
Sports Programming
Other than programming, I'm addicted to sports. I'd like to integrate the two together. What are different programming languages that companies like ESPN use to work with stats? What techniques are used to do this, and how can I get going with it myself?</p>

答:
Nobody can really answer this with certanty and yet cover everything, but my guess is that they use numerous languages, depending on the particular need at hand. For example, if you search for available vacancies at ESPN you'll get a glimpse of what is used.

As far as techniques, most of it is rather fundamental statistics.

Title: Sports Programming


问:
Do you tend to write your own name or your company name in your code?
I've been working on various projects at home and at work, and over the years I've developed two main APIs that I use in almost all AJAX based websites. I've compiled both of these into DLLs and called the namespaces Connell.Database and Connell.Json.

My boss recently saw these namespaces in a software documentation for a project for the company and said I shouldn't be using my own name in the code. (But it's my code!)

One thing to bear in mind is that we're not a software company. We're an IT support company, and I'm the only full-time software developer here, so there's not really any procedures on how we should write software in the company.

Another thing to bear in mind is that I do intend on one day releasing these DLLs as open-source projects.

How do other developers group their namespaces within their company? Does anyone use the same class libraries in personal and in work projects?

Also does this work the other way round? If I write a class library entirely at work, who owns that code? If I've seen the library through from start to finish, designed it and programmed it. Can I use that for another project at home?

Thanks,

Update

I've spoken to my boss about this issue and he agrees that they're my objects and he's fine for me to open-source them. Before this conversation I started changing the objects anyway, which was actually quite productive and the code now suits this specific project more-so than it did previously.

But thank you to everyone involved for a very interesting debate. I hope all this text isn't wasted and someone learns from it. I certainly did.

Cheers,

答:
All answers seem to concentrate on ownership.

But ownership and authorship (authors and owners, resp) are different notions.

Author is linked to moral, or inalienable, rights which are:

perpetual

inalienable

Imprescriptible right

Unsizeable

If a work already created, and the proceeds of its exploitation, are liable to be seized by creditors, as the case may be, the latter may not demand that said work be divulged for the purpose of recovering the moneys due by its author.

Moral, or inalienable, author rights cannot be waived under most jurisdictions.

While ownership is related to Economic, aka property,  rights.

Why not just to follow the practice of how scientific articles are being signed, when workers are frequently work as visiting researcher/professor, employed /financed nu multiple entities. or under independent financing of 3d parties: author name + where is the work had been done + credits who financed the work.

Note that these are many to many relationships (one author, anв his work,  can have multiple affiliations and financing).


问:
Can I use my username in a legal license?
I have an open source project, but I don't want to use my real name in the license file.  Legally, can I just use my project hosting username instead?

I know programmers Are Not Lawyers™, but I'm looking for advice from people who may have dealt with simlar problems.

答:
Copyright law permits anonymous and pseudonymous works. Though, anonymous or pseudonymous,  is not synonymous to unidentifiable:

"(3) if the work is anonymous or pseudonymous, the nationality or domicile of the author or authors;" required for  registration of copyright

Though, copyright is far from always needs registration.

So, the answer is definite "yes"

Note also about differences between ownership and authorship


答: STATS, a joint venture of the AP and News Corp, is one of the leading provider of statistics to broadcast networks like Fox and others.  Currently their Careers page however only lists one position for a web developer for fantasy sports, so it is difficult to answer your question in more detail.</p>

Title: Sports Programming

Body: Other than programming, I'm addicted to sports. I'd like to integrate the two together. What are different programming languages that companies like ESPN use to work with stats? What techniques are used to do this, and how can I get going with it myself?</p>


问:
How was Git designed?
My workplace recently switched to Git and I've been loving (and hating!) it. I really do love it, and it is extremely powerful. The only part I hate is that sometimes it's too powerful (and maybe a bit terse/confusing).

My question is... How was Git designed? Just using it for a short amount of time, you get the feel that it can handle many obscure workflows that other version control systems could not. But it also feels elegant underneath. And fast!

This is no doubt in part to Linus's talent. But I'm wondering, was the overall design of git based off of something? I've read about BitKeeper but the accounts are scant on technical details. The compression, the graphs, getting rid of revision numbers, emphasizing branching, stashing, remotes... Where did it all come from?

Linus really knocked this one out of the park and on pretty much the first try! It's quite good to use once you're past the learning curve.

答:
Git was not designed as much as evolved.

Take a look by yourself. Clone the official git repository, open it in gitk (or your favorite graphical git log viewer), and look at its earliest revisions.

You will see it originally had only the very core functionality (the object database and the index). Everything else was done by hand. However, this small core was designed to be easily automated via shell scripting. The early users of git wrote their own shell scripts to automate common tasks; little by little, these scripts were incorporated into the git distribution (see for an early example 839a7a0). Every time there was a new need, the scripts were adapted to allow for it. Much later, several of these scripts would be rewritten in C.

This combination of a clean, orthogonal core (which you can still use directly if you have the need), with an upper layer which grew organically over it, is what gives git its power. Of course, it is also what gives it the large amount of oddly-named commands and options.

The compression, the graphs, getting rid of revision numbers, emphasizing branching, stashing, remotes... Where did it all come from?

A lot of that was not there in the beginning.

While each object was individually compressed, and duplicates were avoided by their naming, the "pack" files which are responsible for the high compression we are used to seeing in git did not exist. The philosophy in the beginning was "disk space is cheap".

If by "the graphs" you mean graphical viewers like gitk, they appeared later (AFAIK, the first one was gitk). AFAIK, BitKeeper also had a graphical history viewer.

Getting rid of the version numbers, in fact git's core concept of using a content-addressed filesystem to store the objects, mostly came from monotone. At that time, monotone was slow; if this were not the case, it is possible Linus would have used it instead of creating git.

Emphasizing branching is somewhat unavoidable on a distributed version control system, since each clone acts as a separate branch.

Stashing (git stash) is, IIRC, quite recent. The reflogs, which it uses, were not there in the beginning.

Even remotes were not there initially. Originally, you copied the objects by hand using rsync.

One by one, each of these features was added by someone. Not all of them — perhaps not even most of them — were written by Linus. Every time anyone feels a need which git does not fulfill, one can create a new feature over git's core "plumbing" layer, and propose it for inclusion. If it is good, it probably will be accepted, enhancing git's utility (and its command line complexity) even further.

Title: How was Git designed?


问:
How to deal with different programming styles in a team?
We have a small dev team (only 3 developers) and we recently got
a new team member. While he is a smart coder, his coding style is
completely different from ours. Our existing code base contains
mostly readable, clean and maintainable code, but the new team
member is quickly changing many files, introducing ugly hacks and
shortcuts, using defines all over the place, adding functions in
the wrong places, etc.

My question is if others have experienced such a situation
before, and if anyone has tips on how to talk to him.

答:
Yes, I've experienced that before. When working in a team, team members must agree on certain rules and conventions, and that includes the style.

You should have your team sit down together and draft a set of rules, coding standards, that you would require every piece of the checked in code to adhere to.

Most probably, the base for your set of rules, re the styling at least, would be the existing code. Once its done, everyone must comply, and it should be inspected as part of the code review. Code not adhering to the standards should not be allowed to be checked in.

It doesn't have to be a democratic vote, by the way, its one of the things where the team leader can actually execute some authority. But having said that, I don't think that you can impose standards that the majority of the team rejects. You can impose standards that a single person, especially a new one, rejects.

As to how to talk to him... Every experienced programmer knows that each place and team has its own conventions and style, that should be followed. You can tell him that he's more than welcome to suggest improvements, but he has to comply with the rules the team has, and he shouldn't change the style of the existing code but rather use the same style when adding new code.

Also, you can tell (if you're the manager, or talk to your manager about it) to that person not to do certain things that you deem inappropriate (you mentioned defines, order, hacks and shortcuts, and such).


答:
Here's what can be done:

Write a document explaining the coding style required and make everyone in the team learn it. Collect information from every team member.

divide tasks in such way that every team member is responsible of their own piece, and can decide conventions of that part of the code. If any problems are found, whoever wrote it will fix the problems.

add an automatic tool to version control which fixes indentation and other stuff every time code is committed to the version control

Different programmers always have different programming style, and later it can be difficult to change. Best way to handle it is to share information between team members so that everyone learns what styles people have used. If you have a team member who writes different code, it's a chance for your existing team members to learn the new style.

One good trick is to never modify existing code. Instead of modifying the code, write new code by replacing empty lines with new code. And once the code is ready, do only smallest amount of modifications to existing system to take the new code into use. This avoids tweaking existing code, possibly breaking what was already working fine.

Here's what to avoid:

deciding that someone's code is better or worse than other team members. It just doesn't work like that -- everyone knows certain subset of the language well enough to use it in code. Every programmer has chosen different subset to learn, and unless they learned it together, it's going to look different.

Changing how someone writes code. All you get by forcing people to write unfamiliar style is that you get large amount of bugs in the code. People just do not know enough details of something they use the first time. Programmers always choose a subset of language and use that alone. If your programmers have written thousands of lines of code that's filled with gotos, then gotos are going to give you code that has least amount of bugs.

You also shouldn't think that your existing codebase is nice, clean, maintainable stuff. There is always things to improve. But also every change blurs the original design idea that was written to it. Aim to write perfect code the first time, so that the changes won't be needed later. (the new guy wouldn't need to "break" your perfect code, if it was done correctly the first time)

Title: How to deal with different programming styles in a team?

Body:
We have a small dev team (only 3 developers) and we recently got
a new team member. While he is a smart coder, his coding style is
completely different from ours. Our existing code base contains
mostly readable, clean and maintainable code, but the new team
member is quickly changing many files, introducing ugly hacks and
shortcuts, using defines all over the place, adding functions in
the wrong places, etc.

My question is if others have experienced such a situation
before, and if anyone has tips on how to talk to him.


答:
I work with a team that grew from 2 developers to 10 in less than a year. I was number 3, and the first to raise a coding standards issue. The two original developers had been  working side by side for a few years and they'd adopted a common standard that seemed alien to me. We had exactly the same problems you are describing.

What we did was:

Research coding standards

We spent a few days checking out established open source projects. We knew the team would expand rapidly and we were looking for real solutions based on real projects not some generic guidelines. Also we didn't care for the optimal coding standards, but for a set of rules and guidelines that would make sense and not call for the refactoring of all of our codebase. We were looking for a coding standards hack if you will.

The three of us decided that the best coding standards out there for an established PHP project were those followed by Zend Framework. Fortunately the Zend Framework people provide a very comprehensive coding standards document.

Creating our own coding standards

Of course applying another project's coding standards on our project as is didn't make sense. We use the Zend Framework document as a template:

First we removed everything that didn't apply to our project

Then we changed everything that we perceived as a matter of style to our style

And finally we wrote everything down

So we had a fairly large document at our hands, stored in our fancy wiki, it was a nice read, agreed upon by all of us. And completely useless on its own.

Staying true to our promise

Our codebase at the time was about 1*10^6 sloc. We knew that since we adopted formal coding standards we had to start refactoring our code, but at the time we were pressed with other issues. So we decided to just refactor our very core libraries, a mere 5*10^3 sloc.

We assigned one of us to be the coding standards master (we used local profanity in place of master) with the responsibility of checking and enforcing the standards. We recycle the role every few sprints. I was the first, and it was a lot of work, as I had to monitor almost every commit.

We had several new discussions and small addendums to the original document during my tenure, and finally we had a somewhat stable document. We change it every now and then but most of these changes are on new features of the language, as PHP 5.3 was a major release in all but name.

Dealing with the new guy

When the next new guy arrived, it was time to put our coding standards to the test. After a small introduction to our codebase, we asked him to evaluate our coding standards document. He almost cried. It appeared that he did everything differently.

As I was the coding standards master at the time, it was up to me to evaluate his input and revise the document accordingly. His proposals were:

Matters of personal style (summarily dismissed)

Standards that made sense to his Java background but no so much with PHP (dismissed)

Conventions that he carried from his brief exposure with PHP (some were dismissed, but a lot proved to be popular conventions that we never thought of or found out in our initial research)

For the next couple of weeks he was assigned a simple task: Bring several parts of our codebase up to date with the standards. I had to carefully choose those parts based on a few rules:

Code should be relatively easy for someone unfamiliar with our codebase (and PHP in general)

Code should be on what he was hired to do

I monitored his process and he did a fine job. We identified several parts of code that was impossible to fit our document and revised accordingly (code and / or standards, whichever made more sense)

And then another new guy arrived. We repeated the process (different master this time), and it worked again. And again.

In conclusion

Create a coding standards document, but make sure that your standards are not exclusively your own but do reflect common standards in the wider community of your platform.

Assign a similar role to our coding standards master. Someone to monitor at least new code, and especially new code from new members. Recycle the role, as it's extremely boring.

Always evaluate input from a new member. Always revise your standards if it makes sense. Your coding standards document should be evolving, but slowly. You don't want to re-refactor your codebase at each iteration.

Allow for some time for each new member to learn and adapt to your standards and conventions. Learn by doing works best in these situations.

Wiki works wonders for such documents.

Code reviews work wonders for any situation!

At some point in the process it was suggested that we use a pre-commit hook to automate checking of the standards. We decided against it for a variety of reasons, there are some interesting discussions on StackOverflow on the issue:

SVN automatic code formatting on check in?

Version Control and Coding Formatting

PHP codesniffer (phpcs) - how to allow override when using as part of a svn pre-commit hook?

SVN Pre-commit hook to be triggered for a particular folder

Implementing PHP Coding Standards

Some are PHP specific, but the answers apply to all platforms.


问:
Is it possible to effectively develop PHP applications on Windows that will be deployed on servers running Linux?
Is it fine to code PHP on Windows and host it later on a server running Linux? Can there be any problems in the migration of such a project?

I would think that there really can't be any problems, especially since I am a beginner in PHP and I won't use any of the advanced functions that may be OS-specific. However, I would like to make sure since I really don't like Linux at all.

答:
Set yourself up with a Linux testbed. It could be a virtual Linux computer running under Windows, it could be a dual-boot computer, it could be a friend's system. Then, every once in a while (e.g. Monday mornings), port your code over to the Linux system and test it.

The other answers handled the primary problems you will face, but there are numerous smaller gotchas, like:

the temp directory is in a different place

file and directory permissions are different

the system() function changes radicaly

The user name that Apache runs as changes

Things that work under Windows XP may fail under Windows 8.

Yes, there are ways to carefully work around all of these differences, but were you careful to use the work-arounds? Of course not - you coded and it ran so it must be OK.

Don't put anything on a host computer until it has been tested on a similar operating system.

I have no experience porting from Windows to Linux, but I have some experience porting from Linux to Windows and more experience porting from Linux to OS X. It can be done, but the keys are is testing, testing, and testing.


问:
Traditional ASP.Net WebForms vs ASP.Net MVC

Possible Duplicate:

  When to favor webforms over MVC

ASP.Net MVC has been around for some time now. The latest one, i.e MVC3 comes with Razor View Engine.

My question: How long is traditional ASP.Net here to stay. Does Microsoft have any plans to eliminate it in aid of ASP.Net MVC in the future and will the next release of VS incorporate it?

Also, I would like to know if there is any merit of traditional over ASP.Net MVC, other than the controls-aid?

答:
It seems only natural that Microsoft will try to push mvc adoption for ASP.NET, to catch up with the competition. Since the early days of ASP.NET MVC, most articles on ASP.NET on MSDN Magazine seem to feature the framework as do most articles from the news and community content section of asp.net.

I consider the above strong hints, but nothing more. Even if pushing the mvc approach is evident, that doesn't mean that the event driven approach will stop being focal to ASP.NET anytime soon. Microsoft were extremely late in adopting MVC so they are now pushing hard to fill the blanks.

Also note that I'm not suggesting that event-driven is bad and mvc is good. Both architectures have their valid uses and distinct merits. What was pretty bad, was that up until recently there wasn't an easy way to implement mvc on ASP.NET so people would have to get extra creative with the event driven approach in cases where mvc would be more appropriate.

So, no I don't see Microsoft giving up the event driven approach in favor of mvc, it doesn't make sense.


问:
How to Deliberately Practice Software Engineering?
I just finished reading this recent article. It's a very interesting read, and it makes some great points. The point that specifically jumped out at me was this:

The difference was in how they spent this [equal] time. The elite players
  were spending almost three times more hours than the average players
  on deliberate practice — the uncomfortable, methodical work of
  stretching your ability.

This article (if you care not to read it) is discussing violin players. Of course, being a software engineer, my mind turned towards software ability. Granted, there are some very naturally talented individuals out there, but time and time again, it is those folks who stretch their abilities through deliberate practice that really become exceptional at their craft.

My question is - how would one go about practicing the "scales" of software engineering and computer science? When I practice the piano, I will spend more of my time on scales and less on a fun song. How can I do the same in developing software?

To head off early answers, I don't feel that "work on an open source project," and similar answers, is really right. Sure...that can improve your skills, but you could just as easily get stuck focusing on something that is unimportant to your craft as a whole. It can become the equivalent of learning "Twinkle Twinkle Little Star" and never being able to play Chopin.

So, again, I ask - how would you suggest that someone deliberately practice software engineering?

答:
How does a writer practice writing books?

OK, what I meant to say is that writing code is not like mastering a musical instrument. The role of a programmer is more of a writer or a composer trying to find the right chord. So you should ask yourself how these professionals practice their craft instead. Actually, I think our profession has more in common with those than with other engineering disciplines.

A writer practices writing by writing books and a composer practices composing by composing music, so a programmer should practice programming by programming.


问:
How do I do TDD on embedded devices?
I'm not new to programming and I've even worked with some low level C and ASM on AVR, but I really can't get my head around a larger-scale embedded C project.

Being degenerated by the Ruby's philosophy of TDD/BDD, I'm unable to understand how people write and test code like this. I'm not saying it's a bad code, I just don't understand how this can work.

I wanted to get more into some low level programming, but I really have no idea how to approach this, since it looks like a completely different mindset that I'm used to. I don't have trouble understanding pointer arithmetics, or how allocating memory works, but when I see how complex C/C++ code looks compared to Ruby, it just seems impossibly hard.

Since I already ordered myself an Arduino board, I'd love to get more into some low level C and really understand how to do things properly, but it seems like none of the rules of high level languages apply.

Is it even possible to do TDD on embedded devices or when developing drivers or things like custom bootloader, etc.?

答:
A large variety of answers here... mostly addressing the issue in a variety of ways.

I've been writing embedded low level software and firmware for over 25 years in a variety of languages - mostly C (but with diversions into Ada, Occam2, PL/M, and a variety of assemblers along the way).

After a long period of thought and trial and error, I have settled into a method that gets results fairly quickly and is fairly easy to create test wrappers and harnesses (where they ADD VALUE!)

The method goes something like this:

Write a driver or hardware abstraction code unit for each major peripheral you want to use. Also write one to initialise the processor and get everything set up (this makes the friendly environment). Typically on small embedded processors - your AVR being an example - there might be 10 - 20 such units, all small. These might be units for initialize, A/D conversion to unscaled memory buffers, bitwise output, pushbutton input (no debounce just sampled), pulse width modulation drivers, UART / simple serial drivers the use interrupts and small I/O buffers. There might be a few more - eg I2C or SPI drivers for EEPROM, EPROM, or other I2C/SPI devices.

For each of the hardware abstraction (HAL) / driver units, I then write a test program. This relies on a serial port (UART) and processor init - so the first test program uses those 2 units only and just does some basic input and output. This lets me test that I can start the processor and that I have basic debug support serial I/O working. Once that works (and only then) do I then develop the other HAL test programs, building these on top of the known good UART and INIT units. So I might have test programs for reading the bitwise inputs and displaying these in a nice form (hex, decimal, whatever) on my serial debug terminal. I can then move into bigger and more complex things like EEPROM or EPROM test programs - I make most of these menu driven so I can select a test to run, run it, and see the result. I can't SCRIPT it but usually I don't need to - menu driven is good enough.

Once I have all my HAL running, I then find a way to get a regular timer tick. This is typically at a rate somewhere between 4 and 20 ms. This must be regular, generated in an interrupt. The rollover / overflow of counters is usually how this can be done. The interrupt handler then INCREMENTS a byte size "semaphore". At this point you can also fiddle around with power management if you need to. The idea of the semaphore is that if its value is >0 you need to run the "main loop".

The EXECUTIVE runs the main loop. It pretty much just waits on that semaphore to become non-0 (the I abstract this detail away). At this point, you can play about with counters to count these ticks (cos you know the tick rate) and so you can set flags showing if the current executive tick is for an interval of 1 second, 1 minute, and other common intervals you might want to use. Once the executive knows that the semaphore is >0, it runs a single pass through every "application" processes "update" function.

The application processes effectively sit alongside each other and get run regularly by an "update" tick. This is just a function called by the executive. This is effectively poor-mans multi-tasking with a very simple home-grown RTOS that relies on all applications entering, doing a little piece of work and exiting. Applications need to maintain their own state variables and can't do long running calculations because there is no pre-emptive operating system to force fairness. OBVIOUSLY the running time of the applications (cumulatively) should be smaller than the major tick period.

The above approach is easily extended so you can have things like communication stacks added that run asynchronously and comms messages can then be delivered to the applications (you add a new function to each which is the "rx_message_handler" and you write a message dispatcher which figures out which application to dispatch to).

This approach works for pretty much any communication system you care to name - it can (and has done) work for many proprietary systems, open standards comms systems, it even works for TCP/IP stacks.

It also has the advantage of being built up in modular pieces with well defined interfaces. You can pull pieces in and out at any time, substitute different pieces. At each point along the way you can add test harness or handlers which build upon the known good lower layer parts (the stuff below). I have found that roughly 30% to 50% of a design can benefit from adding specially written unit tests which are usually fairly easily added.

I have taken this all a step further (an idea I nicked from somebody else who has done this) and replace the HAL layer with an equivalent for PC. So for example you can use C / C++ and winforms or similar on a PC and by writing the code CAREFULLY you can emulate each interface (eg EEPROM = a disk file read into PC memory) and then run the entire embedded application on a PC. The ability to use a friendly debugging environment can save a vast amount of time and effort. Only really big projects can usually justify this amount of effort.

The above description is something that is not unique to how I do things on embedded platforms - I have come across numerous commercial organisations that do similar. The way its done is usually vastly different in implementation but the principles are frequently much the same.

I hope the above gives a bit of a flavour... this approach works for small embedded systems that run in a few kB with aggressive battery management through to monsters of 100K or more source lines that run permanently powered. If you run "embedded" on a big OS like Windows CE or so on then all the above is completely immaterial. But that's  not REAL embedded programming, anyhow.

OwnerDisplayName: Darth

Title: How do I do TDD on embedded devices?


问:
Differences between programming in school vs programming in industry?
A lot of students when they graduate and get their first job, feel like they don't really know how to program even though they may have been good programmers in college.

What are some of the differences between programming in an academic setting and programming in the 'real world'?

答:
They face a different aspect of the problem:

Academia is mainly focused on the "science of programming" thus studying the way to make efficient particular algorithm or developing languages tailored to make certain paradigms more expressive.
Industry is mainly focused in producing things that have to be sold. It has to rely on "tools" that are not only the languages and the algorithms, but also the libraries, the frameworks etc.

This difference in "focus" is what makes a academic master in C practically unable to write a windows application (since we windows API are not in the C99 standard!), thus feeling as it is "unable to program".
But, in fact, he has all the capabilities to learn itself what he's missing. Something that -without proper academic studies (not necessarily made in Academia)- is quite hard to find.


答:
If you look at the subjects studied in IT in academia, you will find about half of the time wasted in math, science, electives, etc. and the other half on academic subjects such as: Compiler design, Theory of algorithms, Computer Architecture, Optimization, Operating Systems, Digital Electronics, and few other courses related to industry such as C programming and Web Programming.

Most of the above mentioned subjects are nice-to-know but will not either directly provide a strong background in what is required in day-to-day IT.

Take the Microsoft Web Programming requirements (that is, areas required by someone to be a productive team member in an organization):

1- C#.NET or VB.NET

2- ASP.NET

3- HTML and CSS

4- SQL Server (or another database)

5- OO application programming and design

6- Java Script

7- MVC framework

8- Some exposure to source control tools

9- Some exposure to automated testing tools

10-Bug tracking tool

11-E-Commerce Concepts (optional)

12-ORM

13-Some business analysis skills

14-Some communication skills

15-Probably, some cloud computing fundamentals

As you can see that most of the requirements above are rarely focused on (you may get 1 course in some at the most) during college/university.

One can't fully blame institutions since there are many such stacks of technology and they keep on changing.

Most of the above from Microsoft will not help someone who wants to develop applications in Java.

The real problem is that not one of the technology stacks that are needed by the business today is ever covered in full.

The above covers the question of suitability of graduates to business jobs like programming in business environment. The needs to research labs, etc. is not covered by this answer. Also other areas require more skills than the above, such as Game Development, Embedded Development, Real-Time Systems Development, etc.

Title: Differences between programming in school vs programming in industry?

Body:
A lot of students when they graduate and get their first job, feel like they don't really know how to program even though they may have been good programmers in college.

What are some of the differences between programming in an academic setting and programming in the 'real world'?


问:
What advantages do we have when creating a separate mapping table for two relational tables
In various open source CMS, I have noticed that there is a separate table for mapping two relational tables. Like for categories and products, there is a separate product_category_mapping table. This table just has a primary key and two foreign keys from the categories and product tables.

My question is what are the benefits of this database design rather than just linking the tables directly by defining a foreign key in either table? Is it just matter of convenience?

答:
Such a table is often referred to as a link table or bridge table.

It is the standard way of creating a many-to-many relationship. With a direct foreign key between the two tables, you can only create a one-to-many relationship (because the primary key that the foreign key points at is also a unique constraint), or a one-to-one relationship (if the foreign key itself is also a unique constraint).

Depending on the DB design philosophy, the primary key column is often left out, and the primary key of the bridge table is composed of the two foreign key columns themselves (you need a unique constraint on these columns anyway, so why not make it the primary key?).


问:
Language agnostic programming books
Are there any great programming or software development books that are language agnostic?  Why should I read it?</p>

答:
Code Complete 2

Pragmatic Programmer

Design Patterns Explained

Writing Solid Code

Refactoring - Martin Fowler (He's got a few
actually all worthwhile)

Clean Code

97 things Programmers should    know.

These are all books I've either read through completely or reread
   significant portions of a few times and are well put together. I'm a
   newcomer to programming as a whole so I've used these to get
   contextual understanding of what I should learn how to do.

Oh for the database stuff

The Art of SQL

Simply SQL

SQL For Smarties - Joe Celko

These all spring to mind off the top of my head, so forgive me for
not recalling all the authors-I was on my way to another post about
memorising syntax :).

Title: Language agnostic programming books


答:
That's an easy way to implement many-to-many relationships.

Consider this two tables:

```<code>category
--------
categoryID [PK]
categoryName

product
-------
productID [PK]
productName
</code>```

If you add a categoryID field to product, every product can have only one category. But if we have a product_category_mapping like this:

```<code>product_category_mapping
------------------------
mappingID [PK]
productID [FK]
categoryID [FK]
</code>```

then we can have:

```<code>mappingID  productID  categoryID
--------------------------------
1          1          1
2          1          2
3          2          3
4          2          1
</code>```

So product 1 is of category 1 & 2 and product 2 is of category 3 & 1, so many products belong to many categories, and many categories have many products.

As tdammers writes, this table is often referred to as a link table or bridge table, and I've even seen it referred as a HABTM table, from HasAndBelongsToMany which is apparently Ruby on Rails speak for many to many. And Wikipedia calls it a junction table and has quite a few more names for it.

Title: What advantages do we have when creating a separate mapping table for two relational tables

Body:
In various open source CMS, I have noticed that there is a separate table for mapping two relational tables. Like for categories and products, there is a separate product_category_mapping table. This table just has a primary key and two foreign keys from the categories and product tables.

My question is what are the benefits of this database design rather than just linking the tables directly by defining a foreign key in either table? Is it just matter of convenience?

Body:
That's an easy way to implement many-to-many relationships.

Consider this two tables:

category
--------
categoryID [PK]
categoryName

product
-------
productID [PK]
productName

If you add a categoryID field to product, every product can have only one category. But if we have a product_category_mapping like this:

product_category_mapping
------------------------
mappingID [PK]
productID [FK]
categoryID [FK]

then we can have:

mappingID  productID  categoryID
--------------------------------
1          1          1
2          1          2
3          2          3
4          2          1

So product 1 is of category 1 & 2 and product 2 is of category 3 & 1, so many products belong to many categories, and many categories have many products.

As tdammers writes, this table is often referred to as a link table or bridge table, and I've even seen it referred as a HABTM table, from HasAndBelongsToMany which is apparently Ruby on Rails speak for many to many. And Wikipedia calls it a junction table and has quite a few more names for it.


问:
Why did visual programming never take off and what future paradigms might change that?
As the number of "visual" OS's such as Android, iOS and the promised Windows 8 are becoming more popular, it does not seem to me that we programmers have new ways to code using these new technologies, due to a possible lack in new visual programming languages paradigms.

I've seen several discussions about incompatibilities between the current coding development environment, and the new OS approaches from Windows 8, Android and other tablets OS's. I mean, today if we have a new tablet, it's almost a requirement for coding, to have, for instance, an external keyboard (due it seems to me it's very difficult to program using the touch screen), exactly because the coding assistance is not conceived to "write" thousands of lines of code.

So, how advanced should be the "new" visual programming languages paradigms? Which characteristics these new paradigms would be required?

答:
There are a few visual programming tools available, but for all I know, they are all horrible.

UML, which is basically a declarative visual language, is excellent for expressing the big picture, but for fleshing out the details of an implementation, it quickly becomes overwhelming and confusing. There are a few programming environments where you can create code by combining basic building blocks into something that looks a lot like a circuit diagram, but just like UML (or even more so), such diagrams quickly become confusing. Visual Studio, NetBeans, eclipse, and probably a bunch of other IDEs include visual designers for things like web pages and dialogs, and they mostly work, but despite their often astonishing quality, it is still impractical to build an application entirely in designer mode - text mode ultimately gives more control.

An important reason may be that programmers are the ultimate power users. Graphical interfaces excel at shallow learning curves; their intuitive interfaces make it easy to start using them, but the hand-eye coordination required to use them, as well as the mandatory visual feedback loop (you can't click something unless you can see where it is), somewhat limit the maximum input speed vs. a completely keyboard-driven system: physical keys never move, the expected response to a keypress can be anticipated upon, so even if you type into a sluggish ssh terminal session, you can keep typing without immediate feedback.

Another reason is that the meaning contained in source code has many overlapping levels. In a typical OOP project, you have a class hierarchy, which is basically a tree structure, with interfaces implementing cross references through the hierarchy. You have the code flow; imagine a huge flowchart to get an idea about the complexity of that layer. Then there's data structures, also embedded into the code - trees, lists, key-value collections, circular lists, hashmaps, etc. etc. If you're using threading, you introduce yet another level of meaning. With textual source code, you can look at the same piece of code with a different mindset and look at individual levels, zoom in and out, just by looking at the code differently. With graphical programming tools, you would have to switch to a different view - I can't imagine a graphical representation that contains flow, class hierarchy, data structures and threading relations at the same time.

And then there's the huge battery of text-based tools that we use on our code to make our lives easier: text-based search-and-replace, diff, version control, static code analysis, copy-paste (which does have its uses, e.g. for refactoring), code generators, etc.; also, embedding code into an e-mail or copy-pasting a chunk of code into a bug tracker are trivial. Basically, by making all code files text files, we can use battle-hardened tools that have been perfectioned for decades on code written in current and future programming languages.

On a well-meant side note: Are you seriously using a tablet to write code? Really? I would hate that; I always assumed people used a powerful desktop to build the code, and a tablet connected to it to run it.

OwnerDisplayName: Rego


答: In the academic world, most people study computer science or related courses. Dijkstra once observed that "Computer science is no more about computers than astronomy is about telescopes." A person studying computer science is first and foremost learning to become a scientist, and not a programmer. As a programmer, he'll stay an amateur, and the transition to a professional programmer is accordingly hard.</p>


问:
Which license for commercial software?
At the moment we are writing modules for an open source cms.
We would like to sell these with a license.

But which are the best options?
Any suggestions and experiences.

答:
At the moment we are writing modules for an open source cms. We would like to sell these with a license.

Check if you can sell them with the license of the CMS. If it's possible, you can sell them with that license.

But which are the best options? Any suggestions and experiences.

Options depend on what you can do and what you want to achieve. You have not told with your question, so that part can not be specifically answered.

Normally all licenses that allow commercial re-distribution of modified works should be suitable.

OwnerDisplayName: Frederik Heyninck

Title: Which license for commercial software?


答:
The reason to use a mapping table is to eliminate duplication. Go ahead and try some other mapping technique. You won't be able to prevent duplicate data without it.

And that brings a 2cd question. Why bother to eliminate duplication? So you only have to edit data 1 time in 1 place. Sometimes there are performance penalties for eliminating duplication. Other times there are performance INCREASES for eliminating duplication. For example it's faster to fill a drop down list with normalized lookup values, than selecting distinct duplicate values in a big table.


问:
How to justify having one (or more) mobile developers per platform
I've come across a situation at work where I have to justify why I need one (or more) mobile developers per platform.

Although I'm quite aware of the why (each platform is substantially different, has its own philosophy, etc.) I can't seem to come up with more than that.

Are there any articles I can read or even books that will give me hard data about the advantages?

答: You don't need more justification than the truth. You just need to make it understandable for the decision-makers. They probably have some idea that different programming languages exist. Different platforms usually use different languages, and many programmers only specialize in a handful of them (usually for one platform). Tell them that an iOS programmer is not qualified for Android and vice versa. If needed, illustrate with non-IT examples that they can relate to: e.g. asking an iOS developer to develop for Android is like asking a bridge engineer to engineer a house. Sure, there are common skills between the two, but they are vastly different. If the company develops for both desktop and web, you can also cite that as an example: the two platform needs different programmers. </p>


答:
Our existing code base contains mostly readable, clean and maintainable code

One thing I've learned over the years is that readability is in the eye of the beholder. I've seen many cases where someone's chickenscratch coding style is justified as being "readable", and I've seen perfectly reasonable people argue about which coding styles are the most "readable". Maybe this guy doesn't view your style as readable?

That said, the new guy should conform to your standards, not the other way around.


答:
Someone is in charge - they need to act like it.

If coding style is so important, why wasn't this explained to this
person and let them know that they will not have access to any code
until they learn the rules.

Code Review - apparently you don't have any or it is very weak. See #1.

Make a note in your hiring process, that following the accepted coding styles is a requirement for employment. Now what do you do to those who don't follow the rules? Start by removing their access to live code until they get with the program.

.


答:
There are two things you need to consider:

1) Are there enough hours in the day for a single developer to do all that needs to be done - twice?

The 'default' dev environments for iOS and Android are substantially different, even down to the language (Objective-C on iOS, Java on Android), so it's not like you can write the code with a few macros and run it on both platforms. Essentially it's got to be written twice. That means you are going to have to either pick one for your dev to do first, OR you're going to have to wait twice (or more) as long for a simultaneous release.

2) Can you actually hire a dual-mode developer?

While lots of folks ARE qualified to do both, most are only up to date on one or the other. Can you actually find a good developer who has experience with both platforms in your area? My guess is that such people aren't nearly as common as good single mode developers.

If you can find such a person, you are going to have to pay more for them. If you have little enough work that they will have time for both sets of development, then they'll still probably cost less than two developers, but the minute that person runs out of bandwidth for multiple projects, you'll end up adding another person anyway.

Title: How to justify having one (or more) mobile developers per platform

Body:
I've come across a situation at work where I have to justify why I need one (or more) mobile developers per platform.

Although I'm quite aware of the why (each platform is substantially different, has its own philosophy, etc.) I can't seem to come up with more than that.

Are there any articles I can read or even books that will give me hard data about the advantages?


答:
The biggest difference I have found between academic vs industrial programming is regarding robustness. Most everyone has experienced the "it works for me" paradox in their career, and this is an extension of this condition. In academia, the focus is on the algorithms and functions and little regard is placed on the usability and stability of the software under everyday conditions.

For example, at my office we have an engineer that will take the software and is a master at causing crashes from corner conditions. He will click on a button as fast as he can until something crashes...if an operation takes too long, he will just start clicking randomly around the screen (out of frustration?  IDK....)

Changing our programming philosophies so that we make things "Steve proof" has in general improved the stability of our application.


问:
What techniques would you use for a next generation java web application?
I'm working at a site similar to Foursquare and Yelp, with approximately 100000 unique requests each week that generates content, growing steadily. We are currently using:

Seam as Java web framework.

MySQL as DB

Hibernate as ORM

Hibernate Search as Index

EhCache for Caching.

Since our site is slowly growing out of the current setup and has a lot of legacy code, it is time for us to start thinking about a major refactoring/changing setup.

Web framework

We are not ready to change the language but we are leaning towards Spring Web Framework, since:

Seam is no more.

Almost all of us have worked with Spring and liked it.

DB and ORM

We have done a little research and we are thinking about MongoDB.

Index

Do we need to have a separate Index if we use MongoDB?

Cache

?

So my question is basically:

If you take Spring Web Framework and MongoDB into consideration, how would a good setup be for a web application that is growing and handles a lot of logged in users generating input and performing searches?

EDIT
I would like to thank all of you for taking the time to answer me, but the answer I'm looking for should be more specific:

"We choose Spring as our web framework and Freemarker as our template language since freemarker is fast.... If you use MongoDB you will not need a separate index for doing geo searches since MongoDB supports location-based queries out-of-the-box... I very good cache solution to this setup is.... In my previous project we chose to use Apache Solr as our search platform because this solved the issue with fast updates..."

Thank you // Jakob

答:
You'll want to do some serious research.

Overall

It doesn't sounds like you have a clear idea of the performance profile of your application/tech stack. Where are the pain points? Why does it need replacing?

Take measurements first so that you've got something to measure improvements against going forward.

This will help you avoid adding in unecessary technologies/layers that may help less than you think and in some cases even hinder!

Web Framework Replacement

Have a look at Matt Raible's comparison presentation on JVM Web Frameworks and then drop the 20 criteria he uses into a spreadsheet and apply weightings to them according to your functional and non-functional requirements.

Pick 2-3 that seem to fit your requirements best and prototype some pages/UI/Ux/workflow with those.  Probably spend 2-3 days on each as a minimum (1 week if you can get away with it)

Data Store

What are they chracteristics you need from this data store?  Fast read, slow write? Something else? Distributed? Transactional?

Does it need to be Object based? Relational?

Once you've asked and answered some of these questions then you need to pick 2-3 datastores and prototype with them, much like you would with the web framework choice.  Some of the popular NoSQL DBs at the moment are MongoDB (although it might still have that global lock problem, not sure), Cassandra and CouchDB.  But don't take anyone's else's word for it.  Measure it yourself.

Cloud provisioning

As an aside, have you looked into the financial use case for this?  With your rate of expansion, some private/public cloud options could really help you out.

Hope That Helps (HTH) a little :-)


问:
Which is better : Storing/retrieving images on/from SQL server or in a directory on server
I am working on a project in Asp.net MVC and need to work with images. There is an SQL database with a Product table. Every product in the table will have it's own image. I have two ways to do this :

1) Save the image in a web directory and store the URL on database.

2) Store the image in SQL itself in binary format and then retrieve it.

Which is a better approach ? Mind you, I have no idea how second method works :-P . I will only learn this if there are merits to the second method

答:
I prefer to put binary in the database, but that's primarily because

I know where it is, and I don't need a systems guy to set up a network share or webserver.

I can control who can retrieve the data through my application, rather than rely on permissions on the file system. I can do it on a very granular level very easily.

I get much simpler transactional integrity when inserting files than I would with a file system.

The best argument against database storage are around size - the database might become unmanageable. Much more difficult to do database backups & maintenance; the database is one huge file, whereas if the files are external then you can have some over here and some over there.

If you're using Microsoft, perhaps the best compromise is the FileStream type. It stores the filepath in the database and the files in a folder, but the folder is essentially controlled by SQL. You 'insert' files to the database and they're saved in the folder, and when you 'select' from the database the server will retrieve them from the folder and serve through through the database. In this way you get the best of both worlds - transactions and control, plus the size efficiency of keeping the database small.


问:
What should I do to be language-agnostic?
By now I work with asp.net and C#. I have done a decent work in Java as well. I am planning my career in such a way I should be language-agnostic someday. What are the things that I need to learn?

First would OOP paradigms as its speaks about the Class design. Are there any others?

答:
I don't think you can become truly language agnostic. I find that I "think" in my current language (at the moment C#).

However, having said that, I think you might be able to separate the design from the code by trying to think in pseudo code rather than a specific language, and actually write it down in this format. This could help you concentrate on the design and architecture decisions rather than the implementation in your current language. The drawback with that - as Simon points out - is that the language and framework you ultimately use will inevitably influence the design. So as your design develops it will become increasingly tied to the language & framework.


答:
In a traditional undergraduate computer science program you learn just programming.  But the real world doesn't want people who are just programmers. The real world wants real software engineers. I know many job descriptions don't seem to express this distinction, which only confuses the matter. In the real world you need to be able to:

Gather and analyze requirements when they aren't directly given to you

Design and analyze architecture with near endless possibilities

Create test plans and act on them to evaluate and improve the quality of a system

Work collaboratively on a team of people with different backgrounds and experience levels

Estimate and plan work even if you don't know exactly what to build

Communicate effectively with stakeholders who have different needs that don't necessarily align

Negotiate schedule, budget, quality, and features without disappointing stakeholders

Oh yeah, and you also have to be able to write code too, though that takes, on average, only 40 - 60% of a software engineer's time.

So, it's not that freshly minted computer science undergrads don't know how to program (many are in fact, very good programmers). It's that many of them don't know how to do anything else.


问:
Is Windows a "second class citizen" in the Django community?
I'm currently doing R&D for a web application which we plan to host ourselves initially and then allow customers to self host.

My task has been evaluating web frameworks to see which would give us the biggest productivity initially and ease of maintence while also allowing us to easily support deployment to customer controlled environments.

Our team has experience with ASP.NET (MVC and Webforms) and Ruby on Rails.

Our experience with Rails is that Windows deployment is a very taboo subject and any questions on IRC or StackOverflow are met with knee jerk "why not Linux" responses. However in this case our target market may be running windows or Linux servers.

Is this also the case in Django land?

Is it possible with rubbish performance?

Is it possible with lost of pain?

Is it seen as reasonable and not treated as a completely stupid idea for not wanting to run Linux?

答:
Windows is a second class citizen in most open source communities because it treats them as second class citizens. Development and sysadmin on Windows is unnecessarily painful, especially for people who are used to Unix-based systems.

That said, Python on Windows works very well and Django doesn't do anything particularly abnormal so I don't see why you wouldn't be able to make it work.

I suspect the main issues won't be with Django itself, but the surrounding stuff like mod_wsgi, etc. Windows is bound to get in your way at some point.

"Why not Linux" is a valid question to ask. The cost of one additional server vs the extra time required to deal with Windows will likely decide the answer.


答:
Although this has been asked on StackOverflow, I think there is an automatic assumption among programmers on this subject that may not always hold true, so I'm answering it here. There are situations where placing in the database may be better.

https://stackoverflow.com/questions/5613898/what-about-storing-images-in-sql-server There is a link here that shows file size may matter and placing small images in a database may be better for performance. Currently, 250K to 1 M seems to be the grey area. This is specific to SQL Server 2008. I'm guessing more relational databases are going to break their mold a bit and begin to improve their ability to handle large blobs of data.

They may even be better at indexing and searching blob content. Can't wait for the day when I can query all pictures for those Where Photos.File.FaceCount > 1 to get group photos without someone having to manually create the metadata.

Title: Which is better : Storing/retrieving images on/from SQL server or in a directory on server

Body:
I am working on a project in Asp.net MVC and need to work with images. There is an SQL database with a Product table. Every product in the table will have it's own image. I have two ways to do this :

1) Save the image in a web directory and store the URL on database.

2) Store the image in SQL itself in binary format and then retrieve it.

Which is a better approach ? Mind you, I have no idea how second method works :-P . I will only learn this if there are merits to the second method


答:
Something very similar was discussed where i had answered which was inevitably method 1. You can see here a similar discussion:
How to add image support to client-server database application?

If you ask why, the fundamental reason why i prefer web method is that when any application demands the actual image, it has following single point of failures.

It becomes a must that finally the database needs to retrieve.  The retrieval from DB is more expensive (to other transaction) than retrieval from file system.

Usually there is always some server layer (ASP or C#) which actually makes call to DB (clients, or web browser don't directly call DB). hence, the path has additional point of bottleneck. If there is a static URL (possibly with auth) - the browser can directly fetch rather than going via application server.

Most importantly I guess, when delivering images to many browsers (from a web servers) scaling is much easier that way rather than other way.

Last but most, in many cases, images retrieved using static URLs, can be easily cached by the browser itself to save more resource.

I agree with above answer and the criteria in "To BLOB or Not To BLOB"  but most answers focus on speed of retrieval and size of database as a criteria.

My point is that there is additional criteria - is how often images are going to change, and when and how we want deliver these images is equally a critical criteria.

If content of the image is going to keep changing and application logic needs to process them before delivering it makes more sense to deliver via app server (i.e. you can keep in DB). Where as if images by nature itself is quite static - not changing often and needs to be delivered so many times, (set once read/deliver many times) scenario then, it the web is always a preferred method. this applies irrespective of performance of DB.


问:
Where do you put scenarios on a scrum board?
So traditional scrum board looks something like this

```<code>Backlog       |       Story    notStarted   inprogress    Done
story 1               Story1   tasks
Story 2               Story2   tasks
Story ..
Story n
Epic  x
Epic  x+1
</code>```

However in general a story has many scenarios and when working with BDD you want to write each scenario for a story as Given, when and then. Also the scenarios don't belong in the notstarted column, inprogess or Done as a scenario is not a task.

So you realize that a scenario/s should have their own column between "story" and "notstarted", as a scenario can have many task to be considered done.

If you are going to build your task from scenarios then why would you need the story on the scrum board in the first place, maybe they should be left in the backlog.

Some people put scenarios on the back of each story.

This is a on going debate in my team and I wanted to see if anyone has solved this differently.

Cheers!

答:
My suggestion is to do what is valuable for your team. There is nothing sacrosanct about the traditional scrum board. If you feel that putting scenarios instead of stories gives you better information, then go ahead and do that. Create a board like this if you want

```<code>Scenario  |   Not Started    | In Progress  |  Done
</code>```

The advantage of having stories in the board is that its easy to see when a particular story is done. It helps avoid the case where you finish many scenarios, but none of the stories are complete. If you want to visualise that, then you can do a board like this

```<code>Story  |   Scenario  |   Not Started    | In Progress  |  Done
story1       scen1        task1
                          task2 ----> tasks flow this way
             scen2        task
story2       scen1        task
</code>```

Another thing you might want to do is to convert the tasks into columns. So lets say that your usual tasks are like Coding, Testing etc, then how about a board like this

```<code>Story  |   Scenario Not Started |   Scenario In Dev    | Scenario Test  |  Done
story1           scen1
                 scen2 ----> scenarios flow this way
story2           scen1
</code>```

Another option is to remove the story from the board, and use the card colour to identify the story

```<code>Scenario Not Started |   Scenario In Dev    | Scenario Test  |  Done
   scen1 (red card)
   scen2 (red card) ----> scenarios flow this way
   scen1 (blue card)
</code>```

As you can see, you are only limited by your imagination. Dont be stuck with the "traditional scrum board". Think about what you want to do and create a board that suits you.

Body:
My suggestion is to do what is valuable for your team. There is nothing sacrosanct about the traditional scrum board. If you feel that putting scenarios instead of stories gives you better information, then go ahead and do that. Create a board like this if you want

Scenario  |   Not Started    | In Progress  |  Done

The advantage of having stories in the board is that its easy to see when a particular story is done. It helps avoid the case where you finish many scenarios, but none of the stories are complete. If you want to visualise that, then you can do a board like this

Story  |   Scenario  |   Not Started    | In Progress  |  Done
story1       scen1        task1
                          task2 ----> tasks flow this way
             scen2        task
story2       scen1        task

Another thing you might want to do is to convert the tasks into columns. So lets say that your usual tasks are like Coding, Testing etc, then how about a board like this

Story  |   Scenario Not Started |   Scenario In Dev    | Scenario Test  |  Done
story1           scen1
                 scen2 ----> scenarios flow this way
story2           scen1

Another option is to remove the story from the board, and use the card colour to identify the story

Scenario Not Started |   Scenario In Dev    | Scenario Test  |  Done
   scen1 (red card)
   scen2 (red card) ----> scenarios flow this way
   scen1 (blue card)

As you can see, you are only limited by your imagination. Dont be stuck with the "traditional scrum board". Think about what you want to do and create a board that suits you.

OwnerDisplayName: Siddharta


答:
It sounds like your definition of "scenario" is "BDD test". If that's the case, the scenarios should be part of the acceptance criteria. They don't need their own column any more than individual functions in your code need their own column. Since writing the actual test is a task to be accomplished, you can represent the scenarios as tasks that need to be completed.

My team writes acceptance criteria on separate cards that we tape behind the story card, so you can flip the card up and see the acceptance criteria. You could also do that with your scenarios.

Your other option would be to redefine what you call a story. Call your stories "epics", and call your scenarios "stories". Then, you have one story card for each scenario that you are trying to implement.

Bottom line, though, is do what works for your team. There is no scrum police that will come knocking if you deviate from the standard. If you're really concerned, consider hiring a trained scrum master to come in and do some training or consulting.

Title: Where do you put scenarios on a scrum board?

Body:
So traditional scrum board looks something like this

```<code>Backlog       |       Story    notStarted   inprogress    Done
story 1               Story1   tasks
Story 2               Story2   tasks
Story ..
Story n
Epic  x
Epic  x+1
</code>```

However in general a story has many scenarios and when working with BDD you want to write each scenario for a story as Given, when and then. Also the scenarios don't belong in the notstarted column, inprogess or Done as a scenario is not a task.

So you realize that a scenario/s should have their own column between "story" and "notstarted", as a scenario can have many task to be considered done.

If you are going to build your task from scenarios then why would you need the story on the scrum board in the first place, maybe they should be left in the backlog.

Some people put scenarios on the back of each story.

This is a on going debate in my team and I wanted to see if anyone has solved this differently.

Cheers!


答:
In academia,

DRAWBACKS

We have deadlines which are mainly to score points.

Bugs dont really cause trouble, as most of the projects are never used in real world applications.

PLUSes

We get ample time for research.

Swaying from the initial objectives don't cause much trouble.

In the industry,

We work on projects which will actually be used by corporations.

We work under stress of ever changing client requirements.

Deadlines are rarely flexible, as that could lead to huge financial losses to both the Software firm as well the clients.

Check this out:

http://www.dodgycoder.net/2011/10/how-to-become-better-programmer.html


问:
What's the point of adding Unicode identifier support to various language implementations?
I personally find reading code full of Unicode identifiers confusing. In my opinion, it also prevents the code from being easily maintained. Not to mention all the effort required for authors of various translators to implement such support. I also constantly notice the lack (or the presence) of Unicode identifiers support in the lists of (dis)advantages of various language implementations (like it really matters). I don't get it: why so much attention?</p>

答:
How are you going to type ASCII identifiers on a Chinese keyboard? A few language keywords is one thing, and having to do your whole code that way is another.

Programmers should have the right and ability to call their variables whatever they want. It's none of your business what language that's in.

If you feel so confused reading code with identifiers that have symbols from other people's languages in them, then I'm sure that you exactly understand how confused they feel when they have to use identifiers with symbols from your language in.


答:
Good answers. Let me just add, academic programming tends to be almost toy-like in scale. This is good for teaching.
As a teacher, you are trying to convey ideas most efficiently.
The downside is realistic programming is so qualitatively different, it's hard to bridge the gap.

One area of difference is in performance analysis.
I've written many posts trying to point this out.
Performance analysis is only superficially about algorithms and measuring.
To do it really effectively, you have to approach it as a process of debugging.

Another area of difference is maintainability.
This encompasses everything from style to domain-specific language design.
You can't do it effectively unless you actually know what you're trying to minimize.

These things are not taught, and they make an enormous difference in productivity.


答:
Note to visual programmers - I told you so! In the early eighties I was told about attempts at visual programming and observed that the history of geometry was 2000 years of progress from not very rigorous or well-defined visual representations to precise textual argument, at which point it becomes possible to prove things properly. Note that UML and many other visual modelling languages are in fact only visual representations of underlying network or textual data, precisely so that some rigorous meaning can be defined.

I have been impressed by one non-standard notation - "Parnas Tables" but these are really any more visual than code.

Title: Why did visual programming never take off and what future paradigms might change that?

Body:
As the number of "visual" OS's such as Android, iOS and the promised Windows 8 are becoming more popular, it does not seem to me that we programmers have new ways to code using these new technologies, due to a possible lack in new visual programming languages paradigms.

I've seen several discussions about incompatibilities between the current coding development environment, and the new OS approaches from Windows 8, Android and other tablets OS's. I mean, today if we have a new tablet, it's almost a requirement for coding, to have, for instance, an external keyboard (due it seems to me it's very difficult to program using the touch screen), exactly because the coding assistance is not conceived to "write" thousands of lines of code.

So, how advanced should be the "new" visual programming languages paradigms? Which characteristics these new paradigms would be required?


问:
Where to go from here, how to improve / learn more

Possible Duplicate:

  I'm graduating with a Computer Science degree but I don't feel like I know how to program

I finished University around 4 years ago double degree in Software Eng/Comp Sci. Got my first job at a startup in my final year, was with them for 2.5 years then started my own business.

So far everything is going great, lots of clients and stead work etc, but coming right out of uni and into a start up I never had any form or senior software engineer guiding my work or suggesting improvements etc...

Whats the best way for me to improve & learn more? Books? MS Exams? Other?

I develop in C#, ASP.NET/MVC.

Update
The problem isn't really with releasing products, I've released quite a few which are up and running with customers happy. It's more with quality of code, best practices, how do I know something I am code is correct, it may work but there may be ways of coding it much more efficiently or by adhering to some kind of standard

Cheers for any responses!

Matt

答:
Don't underestimate the learning experience involved in guiding others. You have enough experience that there is a whole bunch of developers out there with less knowledge and less experience. Guiding others can be very challenging to your own knowledge and practices as it requires you to verbalize to others why you do things a certain way.

I also agree with what others have mentioned here, take up another language with a significant different paradigm. Personally, Erlang has worked very well for me to extend my own thinking around programming and there are a lot of takeaways from it that can be applied in an imperative language.


问:
TTS on App Engine
I have written a small front-end to the Festival TTS system using Python/Django. I wish to deploy it on the Google App Engine cloud. A few questions:

My application uses the Festival app 'text2wave'. Will is work on the cloud?

I have used Python primitives like subprocess.call() to invoke the aforementioned program. Will that work?

If your answer to any or both of (1) and (2) is no, is there a free api on the web that I can use (from the appengine)? I read somewhere about placing calls from Phono to a Voxeo backend, but I'm not sure what that means.

I am aware of the Google Translate extension that allows translation using an HTTP GET (REST) request, but here the text is limited to 100 chars. Bad. Plus, they may take it down any point of time.

答:
On the cloud yes, but on App Engine, i don't think so. I see Festival available as an RPM  and also that it is written in C, so it would need to be ported over to GAE to work there.

No, You would likely need to configure a ported version as a Backend or Task in GAE.

I don't know. If you'd like to get more familiar w/ App Engine, CoderBuddy is a quick way to test out some simple apps and start getting a feel for the GAE API's.

Title: TTS on App Engine


问:
Google App. Engine for RoR and Python apps
I fairly understand that this Q+A site is programmers destination and questions on hosting are not permitted here, but anyone who has heard of Google's App. Engine is well aware that this question is suited for this site only.

Google App. Engine supports either Java or Python interpreter. I want to know what type of applications can be hosted on this engine? If my Python or RoR application needs a database behind, will this engine support it?

For RoR applications, which interpreter to choose? What are the advantages of Google App.Engine over a local IDE?

答: If your Python application needs a database behind it, GAE has a Datastore and a Blobstore. Additionally, Google now has an experimental Cloud SQL service available in a Trusted Tester program.</p>


问:
What to use for simple cross-platform games instead of Flash?
In short, for simple games:

Is Flash still a good option for browser-based PC clients? It still has 90%+ penetration.

What is a good alternative for mobile devices? Is HTML5 + JavaScript the choice for mobile? Or does one have to learn a new native language for each target platform? (Android, Apple, Windows Phone)...

If you desire further background: There are more blogs about the official demise of mobile Flash than I can count, along with endless useless and vitriolic comments. I'm actually trying to do something practical: build simple games that can be served accross multiple platforms. Several months ago I plopped down $1100 for CS5.5 Web and am wading into Flash. Bummer. My question to people who actually develop simple games and apps: What platform should I use instead? Is Flash still a sensible platform for web-served PC users?

For example, let's say I build a simple arcade game that I would like to serve as an app to mobile users and as a browser-based game to PC users. Should I still invest the time and effort to learn and develop in Flash for the PC users, while building a parallel code set in some other language for mobile users? My games are simple enough that it would be annoying but not inconceivable to maintain parallel code sets.

答:
You may want to look at using C# - on the windows mobile platforms (Windows Phone and Windows 8) it is supported.

For iOs and Android (as well as Mac and *nix and some other platforms), look at mono. A mobile platform that is based on the mono code is provided (pay for) by Xamarin.

With a good set of wrappers and preprocessor directives you should be able to go with a single codebase (or close to).


问:
Finding header files
A C or C++ compiler looks for header files using a strict set of rules: relative to the directory of the including file (if "" was used), then along the specified and default include paths, fail if still not found.

An ancillary tool such as a code analyzer (which I'm currently working on) has different requirements: it may for a number of reasons not have the benefit of the setup performed by a complex build process, and have to make the best of what it is given. In other words, it may find a header file not present in the include paths it knows, and have to take its best shot at finding the file itself.

I'm currently thinking of using the following algorithm:

Start in the directory of the including file.

Is the header file found in the current directory or any subdirectory thereof? If so, done.

If we are at the root directory, the file doesn't seem to be present on this machine, so skip it. Otherwise move to the parent of the current directory and go to step 2.

Is this the best algorithm to use? In particular, does anyone know of any case where a different algorithm would work better?

答:
I'm currently thinking of using the following algorithm:

Start in the directory of the including file.

Is the header file found in the current directory or any subdirectory thereof? If so, done.

If we are at the root directory, the file doesn't seem to be present on this machine, so skip it. Otherwise move to the parent of the current directory and go to step 2.

Is this the best algorithm to use? In particular, does anyone know of any case where a different algorithm would work better?

I have been working in projects that had a setup like this:

```<code>prj
   |
   +-config.h
   |
   +-sub_A
   | |
   | +-config.h
   | +-...
   |
   +-sub_B
   | |
   | +-config.h
   | +-...
   |
   +-...
</code>```

Those are then referred to as

```<code>#include "config.h"
#include "sub_A/config.h"
#include "sub_B/config.h"
...
</code>```

Simply searching for a header with a matching file name would blow this, which I believe means that a different algorithm would work better.

Title: Finding header files

Body:
I'm currently thinking of using the following algorithm:

Start in the directory of the including file.

Is the header file found in the current directory or any subdirectory thereof? If so, done.

If we are at the root directory, the file doesn't seem to be present on this machine, so skip it. Otherwise move to the parent of the current directory and go to step 2.

Is this the best algorithm to use? In particular, does anyone know of any case where a different algorithm would work better?

I have been working in projects that had a setup like this:

prj
   |
   +-config.h
   |
   +-sub_A
   | |
   | +-config.h
   | +-...
   |
   +-sub_B
   | |
   | +-config.h
   | +-...
   |
   +-...

Those are then referred to as

#include "config.h"
#include "sub_A/config.h"
#include "sub_B/config.h"
...

Simply searching for a header with a matching file name would blow this, which I believe means that a different algorithm would work better.


答:
I think you can go with Flash. Since you are already studying it, there is no new direction to follow. Just keep on learning. Flash will be here for some time, so don't worry.

Besides other than PC, Adobe Flash Player exists for a variety of mobile operating systems, including Android (since version 2.2), Pocket PC/Windows CE, QNX (e.g. on BlackBerry PlayBook), Symbian, Palm OS, and webOS (since version 2.0)

Title: What to use for simple cross-platform games instead of Flash?

Body:
In short, for simple games:

Is Flash still a good option for browser-based PC clients? It still has 90%+ penetration.

What is a good alternative for mobile devices? Is HTML5 + JavaScript the choice for mobile? Or does one have to learn a new native language for each target platform? (Android, Apple, Windows Phone)...

If you desire further background: There are more blogs about the official demise of mobile Flash than I can count, along with endless useless and vitriolic comments. I'm actually trying to do something practical: build simple games that can be served accross multiple platforms. Several months ago I plopped down $1100 for CS5.5 Web and am wading into Flash. Bummer. My question to people who actually develop simple games and apps: What platform should I use instead? Is Flash still a sensible platform for web-served PC users?

For example, let's say I build a simple arcade game that I would like to serve as an app to mobile users and as a browser-based game to PC users. Should I still invest the time and effort to learn and develop in Flash for the PC users, while building a parallel code set in some other language for mobile users? My games are simple enough that it would be annoying but not inconceivable to maintain parallel code sets.


答:
The new  element in HTML5, as well as WebGL makes javascript an excellent choice for making cross-platform games that you can play in browsers. These will work on most systems, and may eventually overcome flash as the choice for developers who create content that would need it. </p>

<p>Flash still has the advantage because of the toolsets that they supply, but eventually I can imagine they will develop a toolset specifically for javascript and . Until then, making games will be much easier using flash, unless you are already equipped to develop in pure javascript. </p>

Body:
The new  element in HTML5, as well as WebGL makes javascript an excellent choice for making cross-platform games that you can play in browsers. These will work on most systems, and may eventually overcome flash as the choice for developers who create content that would need it.

Flash still has the advantage because of the toolsets that they supply, but eventually I can imagine they will develop a toolset specifically for javascript and . Until then, making games will be much easier using flash, unless you are already equipped to develop in pure javascript.


问:
gRaphael plugin best practices
I'm looking for best practices when creating a plugin for gRaphael. I'm looking for something like jquery where in its documentation you have the best practices of how to write a plugin. So far I haven't found nothing so I'm starting to imagine that it just comes down to best practices with javascript and not with a particular order of the code or configurability... any thoughts?</p>

答: On the home page at raphaeljs.com there is links for documentation, user group, and Twitter. What more do you need? It's a neat library with what seems like a small group of users compared to other libraries such as jQuery, sounds like you're on your own.</p>

Title: gRaphael plugin best practices


问:
How to port a J2ME application to Android platform?
I have heard that there are soft wares for converting an existing J2ME app to Android? But I was doing a manual conversion till now. Am I doing a silly job/is it possible to do convert any J2ME application?</p>

答:
I agree with the previous answer that porting your code to native Android is probably your best choice in the long run. Primarily for getting an Android-like user experience but also to take advantage of the more advanced possibilities of the platform. (But be aware that it's not that easy just because both J2ME and Android are phone platforms based on Java. It is a completely different platform.)

If you, despite this, is set on just running your existing J2ME application on Android, one viable alternative is running a J2ME emulator inside of Android. This is how Opera Mini was run on Android, originally. (Maybe it still is, for all I know.)

It sounds difficult, but check out this article on how easy it really is to do this with MicroEmu:

http://microemu.blogspot.com/2009/08/converting-javame-applications-to.html

For the record, I have no affiliation with MicroEmu what so ever. :-)


答:
newcomer,

I've been looking at a similar problem myself and I'm in the process of porting one of my own applications to BlackBerry and Android. In my case, I have a discrete domain layer, so it was easy to plug into other technologies. The only thing required was to wire in the UI and network/infrastructure layers. This worked out well because I could unit test the domain layer without having to start up a simulator, which is a common problem faced in mobile application development. As a bonus, it's Java to Java, so It'll be even easier for you.

Once you've done your port and if you don't have a discrete domain layer, I'd look into refactoring you code to have one in place so that porting becomes easier. Even if it's for another language, technology, all the business logic is in the one place and you don't need to filter through XML parsing, network communication code etc. As a plug, I'd recommend reading Eric Evan's Domain Driven Design. I believe this kind of approach is even more important in mobile development when your porting your app to different platforms. The domain model might not be as rich on the mobile app as you've got limited memory, so some compromises may have to be made, but it's definitely worth aiming for to make the problem you've describe a minor issue.

Title: How to port a J2ME application to Android platform?

Body: I have heard that there are soft wares for converting an existing J2ME app to Android? But I was doing a manual conversion till now. Am I doing a silly job/is it possible to do convert any J2ME application?</p>


问:
Website or any material to practice algorithms that explains the solution
I know some projects and web pages for practicing algorithms like TopCoder and Project Euler. </p>

<p>However, they just dictate the solution of a particular problem. I wonder if there is a resource, website or any material, that doesn't only give away the code, but also explains the solution thoroughly ? </p>

答:
The problems in the Project Euler site at least would cover problems based on background in different areas such as discrete mathematics, number theory, data structures, general theory of algorithms, as well as the knowledge of general problem solving skills. To find more explanation about a specific question, I suggest that you be familiar with the subject of area the questions. For example, to solve the problem "Find the 10001st prime", you need to know about prime number properties which is usually discussed in Number Theory and/or Discrete Mathematics and then use this knowledge to come up with a good algorithm.

Good books on the above subject areas are too many to list (e.g. Problem Solving and Programming Concepts (9th Edition)), you could easily search for them by subject name such as "Problem Solving", but then again, good is somewhat relative and depends on your background and your favorite programming language.

Wikipedia offers good but sometimes complex explanation for most of the above subjects for example prime numbers are discussed in Wikipedia-Prime Numbers and Wolfarm discusses the subject at wolfram Prime Numbers. StackExchange specialty sites should also be consulted for fruitful discussions. This link may be helpful Algorithm Tutorials on Stack Overflow

ACM offers some free books/chapters on: ACMSolver

I hope this helps.


问:
Differences between programming in school vs programming in industry?
A lot of students when they graduate and get their first job, feel like they don't really know how to program even though they may have been good programmers in college.

What are some of the differences between programming in an academic setting and programming in the 'real world'?

答:
Academic programming is more about code it yourself.  This is important in learning how it works.  Code quality and revision control don't count for much.  With notable exceptions, code doesn't have a lifetime beyond the assignment.  The scope of projects tends to be quite constrained, and unlikely to creep.

In the real world, you should have as little original code as possible.  A lot of code is developed by teams.  It is better to use library routines than to code it yourself.   Code quality and revision control become more important.  Code tends to have a lifetime far beyond what was originally expected.  Project scope is usually quite broad and tends to creep significantly if not managed.


答:
I assume you're bothered due to recent news of Adobe ceasing further development of the Flash Player plugin for mobile browsers.

So to make this clear: Adobe dropped the mobile browser plugin, which arguably is a good decision, because on a device where power is scarce, running an app on a VM as a plugin in a browser is a poor distribution method, especially because the typical channel are the respective app stores.

Adobe did not drop any of their tools (because that is what they are making money with). You can still use Flash to create mobile apps, be that with AIR or whatever technology used to actually run your app on the target device. Talk is that Flash will also export to HTML5/JS. Who knows.

What this really means is, that the tools you know, the APIs you learn, the workflows you find for yourself, are largely unaffected by this decision. While the future of the FlashPlayer browser plugin is uncertain beyond mobile platforms, Flash, Flash Builder, Flex and Flash Catalyst do not depend on it and will remain as good an option as they were before (at least in the foreseeable future).

Alternatives I could think of off the top of my head would be playN (Java) and NME (haXe - which is what I'd recommend using), but as I said there is no actual need for switching. If you feel you are going to be happy with the Adobe tools (which an investment of $1100 suggests), then just stick with them. If you're more of a graphical type, then Flash is arguably one of the best things you can get.