答:
Obviously, what you meant to ask is the following. There are many distributions of Linux, and most have their own collection of packages. Who is responsible for providing those distribution-specific packages?

The answer is that in most cases, the maintainers of those packages are people who specialize in building packages. They are not, typically, the the same people who develop the open source projects being packaged.

The reason for this is that packaging is best done by those who know both the distribution and the packaging system inside and out. Maintaining the package-building scripts, across upgrades of a) the software being packaged and b) the distribution, is also a larger job than most people think.

To name some examples:

Debian has numerous packaging teams

Slackware's official packages are maintained mainly by Slackware's one maintainer (with help from a small team), with unofficial ones being maintained by satellite projects such as SlackBuilds, GnomeSlackBuild, and Slacky

Arch, like Debian (and most other distributions), also has an official packaging team, an interview with which you can find here

As to whether it's "spammy" for a developer to provide packages for any specific distribution: no it isn't. The distribution's users will appreciate your support. Furthermore, all Linux distributions (AFAIK) distinguish between official packages (built by the distribution's maintainers) and unofficial ones (built by anyone else).

Title: FOSS Development: Who develops the OS-specific packages?

Body:
I have a couple of FOSS projects. They can be a bit of a pain to get running unless you've got dependencies in place already, which I figure is par for the course for FOSS projects.

We know that each free operating system out there has its own package management systems. A few of them, such as homebrew on Mac OS or AUR on Arch linux are very friendly to community contributions.

What I am wondering is, who exactly is expected to contribute packages? Primarily I am concerned with the case of small or developing projects, since it's pretty standard for the big projects to be put in there by the OS maintainers.

From my perspective, it is something of a chicken-egg problem, because your software will not make its way into a package system if it does not have users, and it is less likely to gain users if it is not easy to install and use.

For the sake of discussion, let's assume that the software in question is actually legitimately useful. I can see where people could create crapware or spam and that should obviously be kept out of any package system.

So, in summary, whose job is this? Is it spammy for a FOSS software dev to put his own work into various OS package repositories?


问:
At which point is a continuous integration server interesting?
I've been reading a bit about CI servers like Jenkins and I'm wondering: at which point is it useful?

Because surely for a tiny project where you'd have only 5 classes and 10 unit tests, there's no real need.

Here we've got about 1500 unit tests and they pass (on old Core 2 Duo workstations) in about 90 seconds (because they're really testing "units" and hence are very fast).  The rule we have is that we cannot commit code when a test fail.

So each developers launches all his tests to prevent regression.

Obviously, because all the developers always launch all the test we catch errors due to conflicting changes as soon as one developer pulls the change of another (when any).

It's still not very clear to me: should I set up a CI server like Jenkins?  What would it bring?

Is it just useful for the speed gain? (not an issue in our case)

Is it useful because old builds can be recreated? (but we can do this to with Mercurial, by checking out old revs)

Basically I understand it can be useful but I fail to see exactly why.

Any explanation taking into account the points I raised above would be most welcome.

答:
Is it just useful for the speed gain? (not an issue in our case)

Any time spent cycling your process is time you could have spent getting into the flow of developing.

You will also save time at milestones because you ideally are building fully packaged and ready-to-ship bits that can be burned straight to CD, uploaded to the web, etc.

Is it useful because old builds can be recreated? (but we can do this to with Mercurial, by checking out old revs)

No, you don't recreate builds.  You use the build it created, and keep it around until your retention settings toss it out.

You build it on the build server, as opposed to on some Dev's box.

Here we've got about 1500 unit tests and they pass (on old Core 2 Duo workstations) in about 90 seconds (because they're really testing "units" and hence are very fast). The rule we have is that we cannot commit code when a test fail.

In addition wouldn't you like to be able to run automated integration or end-to-end tests on your code and catch issues that unit tests won't catch?

You wouldn't want to run those on dev boxes, because it would be a pain to set up and maintain that environment.  Integration tests also tend to be very slow to execute.

at which point is it useful?

It is an investment like any other.

Use it once and you might come out behind or only break even.  Use it on multiple projects and you will probably come out ahead.

It also depends on the type of applications you make.

If you make web applications that need to be deployed to a Java Application Server, or IIS, then CI becomes a no-brainer.  Same if you have a database as part of your project.  Deployment is painful to execute manually, and your QA team (if you have one) will need it as often as daily at some point.

Also, you might want to see how your needs and problems align with Joel Spolsky's 12 Steps to Better Code.  Particularly 2, 3 and 10 (though they're all interesting and important).

ContentLicense: CC BY-SA 3.0


问:
Use open-source programs in your company?
Is there any cons of making your employees use open-source programs in your company?

I am planning to start a bussiness and I wonder why companies usually work with proprietary software, as Microsoft Word to quote the most famous one. Why do not they use Open Office (or Libre Office) etc.?

From my point of view, you can save a lot of money and help the open-source community by, for instance, giving them part of your benefits in form of donations.

I do not know any (medium-big) company that does this. Probably you could give me some examples, just to prove that this model of open-source usage/collaboration works rocks.

答:
Two things others haven't mentioned:

Interoperability with other companies or the public

This is particularly true with consulting companies, but any company could eventually have to release documents to the public.

If companies you partner with are using different products than you, then you may have incompatibilities.  This is mostly going to cause a problem with office software, where you send them a presentation, a spec, a spreadsheet, and they can't open it, or it looks ugly.  One way around this is for everyone to standardize on the same software, and the easiest way to make sure you have the same software is to buy the version that has massive entrenchment.

My pet peeve here: PDF are not standard or the entrenched leader, even though a lot of people think they are.

Bundled contracts

If you are working with Visual Studio, you probably bought MSDN subscriptions, which means you probably get everything else on the Microsoft stack along with it.  This is as good a reason as any to use all of what you've purchased.  You'll be stuck with that software forever, and have added resistance to change it, but that's one reason that companies go all-Microsoft.

I've seen similar negotiations for Flash, Flex, Adobe, and HP products (since HP has the "official" test/project management suite for Flex development).


问:
When to use Constants vs. Config Files to maintain Configuration
I often fight with myself on whether to put certain keys in my web.config or in a Constants.cs class or something like this.

For example if I wanted to store application specific keys for whatever the case may be..I could store it and grab it from my web config via custom keys or consume it by referencing a constant in my constants class.

When would you want to use Constants over config keys?

This question really applies to any language I think.

答:
Personally I would only use constants as default values, and let them be overridden by values from a configuration file.

If the application takes command line arguments, then those would in turn override the configuration file parameters.


问:
What is the best design decision approach?
I have two classes (named MyFoo1 and MyFoo2) that share some common functionality. So far, it does not seem like I need any polymorphic inheritance but, at this point, I am considering the following options:

Have the common functionality in a utility class. Both of these classes call these methods from that utility class.

Have an abstract class and implement common methods in that abstract class. Then, the MyFoo1 and MyFoo2 classes will derive from that abstract class.

Any suggestion on what would be the best design decision?

答:
Are Foo1 and Foo2 actually related (conceptually, that is) or do they simply share some functionality?

If they're conceptually related, I would go with an abstract class.

If they simply share the functionality, I would break out that functionality and make a separate class. You can then use composition to build Foo1 and Foo2.

OwnerDisplayName: palm snow

OwnerDisplayName: Justin Niessner


答:
As always it depends.

If all instaces of Foo1 and Foo2 can logically be called FooParent then use inheritance.

For the utility class to make sense it should be something that be used across multiple projects, think about the Apache libraries on this one.

Typically in these scenarios you want to have Foo1 and Foo2 be composed of FooUtility.

Title: What is the best design decision approach?

Body:
I have two classes (named MyFoo1 and MyFoo2) that share some common functionality. So far, it does not seem like I need any polymorphic inheritance but, at this point, I am considering the following options:

Have the common functionality in a utility class. Both of these classes call these methods from that utility class.

Have an abstract class and implement common methods in that abstract class. Then, the MyFoo1 and MyFoo2 classes will derive from that abstract class.

Any suggestion on what would be the best design decision?


答:
From your question I feel that the two classes Foo1 and Foo2 have no business relationship(because you have specified that you do not need any polymorphic inheritance).

so based on that I would suggest you to use some external Utility class rather than adding an abstract super class. Since relating two classes which are not really related just to share common functionality could compromise/complicate the future expansions of your project.

For example if you have some Foo11 and Foo12 which has business relationship to Foo1 it would be simpler and more logical to use common parent Foo1Parent at that point.

OwnerDisplayName: Low Flying Pelican


答:
As the other posters stated it is difficult to answer the question without knowing the relationship between the classes. The answer is, as always, it depends.

Inheritance should really only be used if you can say "Foo1 is a FooParent". Inheritance is a powerful tool, but it can also tie your hands down the road.

The GoF recommended "composition over inheritance" - using interfaces allows for maximum flexibility. The downside is that you can end up with code bloat if you declare an interface for every little responsibility. Interfaces generally describe what an object does instead of what it is (inheritance).

Theory aside, is the common functionality key to what Foo1 and Foo2 are or do? Or is it more boilerplate code that you'd like to not have to write every time. If it is part of the class behavior, use inheritance. If not, if it's just boilerplate (data access code, validation or security) then a utility class would probably be my choice.

OwnerDisplayName: Mark J Miller


问:
Is COBOL still worth learning?
Does learning COBOL still make sense?</p>

答: Maybe not worth from a work market perspective, but you might want to have a look at it just to get a feel of how stuff was done "in the good ol' day". ^^</p>

ContentLicense: CC BY-SA 2.5

Title: Is COBOL still worth learning?


答:
Value in configuration file is harder to maintain than value in constants class, because the compiler does not check it exists and is of correct type, the IDE usually does not provide code assistance for it and also because it's yet another syntax you have to switch to while programming.

So I would suggest putting:

Values that will be the same in all installations as constants in code. There are some advantages to putting them in one constants class (you can easily try out various values to see how they work) and putting them in the module that uses them (you don't have to open yet another file when modifying that module and avoiding one file that everybody would edit causing conflicts in version control).

Values that (may) need to be changed per installation to config file. And you probably want to put default in the code anyway, so if the value is not set in the config, the application still (somehow) works.

Title: When to use Constants vs. Config Files to maintain Configuration

Body:
I often fight with myself on whether to put certain keys in my web.config or in a Constants.cs class or something like this.

For example if I wanted to store application specific keys for whatever the case may be..I could store it and grab it from my web config via custom keys or consume it by referencing a constant in my constants class.

When would you want to use Constants over config keys?

This question really applies to any language I think.


答:
Changing Constants require re-building the application most of the cases. Put other way, constants remains constants when someone doesn't have an access to code.

So any information that end user need to provide (and need to change) should go in the configuration files. Most others need to go under constants. However, there must be legitimate defaults or error exception handling if the configuration files are broken.

Elements which are not part of the abstraction of the object (i.e if constants which are not meant to be modified by external (calling) objects are likely to be hidden and essentially mean they would be better off as private constants than config files.

When there are many config elements which pertains to different objects, not related to each other, and when so many objects needs to pull out (same or their own) config files, chances are that these things should have been constants.


问:
What are binaries?
I see very often people using term binaries in different context. What are binaries? Collection on binary files, installation files, .dll files or what? Or is it just an general term for some collection of files on disk?

答:
The word binaries is used as a set of files which are produced after compiling essentially the object code that runs on machines. (and virtual machines/runtimes in case of Java/.NET)

While there are other things like JPEG photo, MPEG video, Zip files etc. are also binary in the sense they are not text or ascii files, but word binaries (used in context of software development) doesn't include them.

Title: What are binaries?


答:
Binary means composed of two pieces or two parts and may refer to different things in different worlds of Mathematical, Computing, Science and Others.

But, in Computing, Binary refers to :-

Binary file, composed of something other than human-readable text

Executable, a type of binary file that contains machine code for the computer to execute

Binary code, the digital representation of text and data

Title: What are binaries?

Body: I see very often people using term binaries in different context. What are binaries? Collection on binary files, installation files, .dll files or what? Or is it just an general term for some collection of files on disk?


答:
In the linux/unix world, developers and geeks prefer source code to executable binaries so they can compile and tweak them themselves.

When an app is free that is awesome.  If it is distributed as binary, that is still awesome.  When it is distributed as source that is really awesome.

Title: What are binaries?


问:
What are the pros and cons of storing files in DB2 vs folders?
I work in a Web Application where users are allowed to upload files. They can retrieve and view those files at a later point in time. A solution that user works with can have multiple attachments but the click to view only one at a time. No version maintenance. Users can delete those files. No soft delete. The files are captured with few more fields on the UI and those fields are stored in DB2 table. Files can be max of 5 MB.

Now, would it be appropriate to store these files in DB2 database as BLOB objects (or) would it be appropriate to store them in a folder?  What is the best approach?

答:
If you will only have a small number of files (say, under 10,000) and they are fairly small (such as photos), keep them wherever you want - in the db or in the file structure.  The difference in performance/efficiency wont be noticable for most applications, so just use whichever you are most comfortable with.

Otherwise, you'll find it easier to manage in the long run if they are stored in the file system.  Particularly if these are very important documents - you'll be able to implement much better backup systems, and you wont have to worry about a huge database that will have to span volumes, which may make it difficult to back up.

Keep in mind also, particularly with web applications, the delivery of files stored in the file system does not require using a database connection to transfer the actual file.  Whereas if its in a blob, a database connection and its bandwidth are used.


答:
Courtesy Jeff O

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.

NOTE Please don't upvote this answer, this is just for the OP reference. The words are from someone else's mouth so i should not be the one getting the repo's

Title: What are the pros and cons of storing files in DB2 vs folders?

Body:
I work in a Web Application where users are allowed to upload files. They can retrieve and view those files at a later point in time. A solution that user works with can have multiple attachments but the click to view only one at a time. No version maintenance. Users can delete those files. No soft delete. The files are captured with few more fields on the UI and those fields are stored in DB2 table. Files can be max of 5 MB.

Now, would it be appropriate to store these files in DB2 database as BLOB objects (or) would it be appropriate to store them in a folder?  What is the best approach?


问:
Modern programming language with intuitive concurrent programming abstractions
I am interested in learning concurrent programming, focusing on the application/user level (not system programming). I am looking for a modern high level programming language that provides intuitive abstractions for writing concurrent applications. I want to focus on languages that increase productivity and hide the complexity of concurrent programming.

To give some examples, I don't consider a good option writing multithreaded code in C, C++, or Java because IMHO my productivity is reduced and their programming model is not intuitive. On the other hand, languages that increase productivity and offer more intuitive abstractions such as Python and the multiprocessing module, Erlang, Clojure, Scala, etc. would be good options.

What would you recommend based on your experience and why?

EDIT: Thanks everybody for your interesting answers. It's hard to make a conclusion without actually trying since there are many good candidates: Erlang, Clojure, Scala, Groovy, and perhaps Haskell. I voted the answer with the most convincing arguments, but I'll try all the good candidates before deciding which one to pick :)

答:
You almost certainly should look at Clojure - in my opinion it's the best modern language for multi-core programming and it is extremely productive.

Key attributes:

It's a functional language, which is a boon for both concurrency and your ability to develop using higher level abstractions. It features fully immutable persistent data structures and lazy sequences which will be familiar to anyone with experience in functional languages like Haskell.

It features a very novel software transactional memory system for concurrent lock-free access to mutable state. Making code concurrency-safe is often as simple as wrapping it in a (dosync....) block.

It's a Lisp - which makes it extremely powerful for macro-based metaprogramming and code generation. This can bring significant productivity advantages (essay by Paul Graham - "Beating The Averages")

It's a JVM language - so not only do you get access to the huge array of libraries and tools in the Java ecosystem, you also benefit from the huge engineering effort that has gone into making the JVM an effective platform for concurrent server-side applications. For practical purposes, this gives it a huge advantage over languages that don't have this kind of foundation to build upon.

It's dynamic - which results in very concise code and a lot of productivity. Note however that you can use optional static type hints for performance if needed.

The language is designed around abstractions which is somewhat hard to explain but the net effect is that you get a set of relatively orthogonal features that you can combine to solve your problems. An example would be the sequence abstraction, which enables you to write code that deals with every "sequential" type of object (which includes everything from lists, strings, Java arrays, infinite lazy sequences, lines being read from a file etc.)

There's a great community - helpful, insightful but most importantly very pragmatic - the focus in Clojure is generally on "getting things done".

Some mini code samples with a concurrency slant:

```<code>;; define and launch a future to execute do-something in another thread
(def a (future (do-something)))

;; wait for the future to finish and print its return value
(println @a)

;; call two functions protected in a single STM transaction
(dosync
  (function-one)
  (function-two))
</code>```

In particular, it's worth watching one or more of these videos:

http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey

http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey

http://www.infoq.com/presentations/Clojure-The-Art-of-Abstraction

Body:
You almost certainly should look at Clojure - in my opinion it's the best modern language for multi-core programming and it is extremely productive.

Key attributes:

It's a functional language, which is a boon for both concurrency and your ability to develop using higher level abstractions. It features fully immutable persistent data structures and lazy sequences which will be familiar to anyone with experience in functional languages like Haskell.

It features a very novel software transactional memory system for concurrent lock-free access to mutable state. Making code concurrency-safe is often as simple as wrapping it in a (dosync....) block.

It's a Lisp - which makes it extremely powerful for macro-based metaprogramming and code generation. This can bring significant productivity advantages (essay by Paul Graham - "Beating The Averages")

It's a JVM language - so not only do you get access to the huge array of libraries and tools in the Java ecosystem, you also benefit from the huge engineering effort that has gone into making the JVM an effective platform for concurrent server-side applications. For practical purposes, this gives it a huge advantage over languages that don't have this kind of foundation to build upon.

It's dynamic - which results in very concise code and a lot of productivity. Note however that you can use optional static type hints for performance if needed.

The language is designed around abstractions which is somewhat hard to explain but the net effect is that you get a set of relatively orthogonal features that you can combine to solve your problems. An example would be the sequence abstraction, which enables you to write code that deals with every "sequential" type of object (which includes everything from lists, strings, Java arrays, infinite lazy sequences, lines being read from a file etc.)

There's a great community - helpful, insightful but most importantly very pragmatic - the focus in Clojure is generally on "getting things done".

Some mini code samples with a concurrency slant:

;; define and launch a future to execute do-something in another thread
(def a (future (do-something)))

;; wait for the future to finish and print its return value
(println @a)

;; call two functions protected in a single STM transaction
(dosync
  (function-one)
  (function-two))

In particular, it's worth watching one or more of these videos:

http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey

http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey

http://www.infoq.com/presentations/Clojure-The-Art-of-Abstraction


答:
From my point of view for normal office applications Microsoft is the de facto standard, if you like it or not. So most of your customers, suppliers, subcontrators etc. want to exchange MS Office documents.
One of our biggest customers requires reports as Word 2003 and pdf files.

For SW development it depends on your scenario, we use here a lot OSS like Eclipse, but also Visual Studio, if the project targets mainly Windows.

Needless to say, for a bigger company license costs are no big deal, maintenance costs are the issue. You have these costs also with OSS, if you do it serious.

Title: Use open-source programs in your company?

Body:
Is there any cons of making your employees use open-source programs in your company?

I am planning to start a bussiness and I wonder why companies usually work with proprietary software, as Microsoft Word to quote the most famous one. Why do not they use Open Office (or Libre Office) etc.?

From my point of view, you can save a lot of money and help the open-source community by, for instance, giving them part of your benefits in form of donations.

I do not know any (medium-big) company that does this. Probably you could give me some examples, just to prove that this model of open-source usage/collaboration works rocks.


答:
At which point is it useful?

Your build+test cycle gets over a couple of minutes. With 5 minute test run you will no longer want to run all tests yourself, especially for small changes.

You start building multiple variants. If you have a couple of customers with different customizations, you should run the tests against each variant, so the amount of work will start growing quite fast. Than you'd run the test suite for one variant on developer machine and leave it to CI to run it on the rest.

You write automated integration tests that need some non-trivial test environment setup. Than you want to test against one canonical test environment, since the developers may have their environment modified in various ways due to the development changes. The CI is most suitable place for the canonical environment.

Testers can just pull the latest build from CI. Thus they neither need to have, learn and use the development tools nor has any developer have to send them their build manually.

When you are preparing for release:

Testing becomes more important, so having one place with prepared builds for test is even more useful.

You are certain that all builds are built with the same build environment, so you avoid problems that may be introduced by subtle differences between developer installations.

You are certain that you are building exactly what is checked in the version control system. During development if somebody forgets to check something in, you'll find quite quickly, because it will fail for the next developer. But if such build slipped to QA or production and they report a bug, it would get very hard to trace.

You probably don't need CI just yet, but I think it will become useful when you get to the testing phase. Jenkins is set up in few hours and it will simplify your testing and help avoid silly mistakes (that happen especially when you hurry a quick fix to production).

Title: At which point is a continuous integration server interesting?

Body:
I've been reading a bit about CI servers like Jenkins and I'm wondering: at which point is it useful?

Because surely for a tiny project where you'd have only 5 classes and 10 unit tests, there's no real need.

Here we've got about 1500 unit tests and they pass (on old Core 2 Duo workstations) in about 90 seconds (because they're really testing "units" and hence are very fast).  The rule we have is that we cannot commit code when a test fail.

So each developers launches all his tests to prevent regression.

Obviously, because all the developers always launch all the test we catch errors due to conflicting changes as soon as one developer pulls the change of another (when any).

It's still not very clear to me: should I set up a CI server like Jenkins?  What would it bring?

Is it just useful for the speed gain? (not an issue in our case)

Is it useful because old builds can be recreated? (but we can do this to with Mercurial, by checking out old revs)

Basically I understand it can be useful but I fail to see exactly why.

Any explanation taking into account the points I raised above would be most welcome.


答:
I'd still recommend C++. It is more than capable of the necessary abstractions to write decent concurrent code. The overwhelming probability is that you simply have a poor library for doing the job, since good libraries for doing the job are relatively new, and indeed, the knowledge for using C++ well is not exactly common. Intel's TBB has only been around for a few years, and Microsoft's PPL has only shipped since last year.

If you use something like TBB or PPL, then concurrent code is, well, not exactly trivial to write, insofar that concurrency is never trivial, but far from arduous. If you use pthreads or Win32 threads directly, then it's no wonder you don't like it- you're practically writing in assembler with such functions. But with the PPL, then you're talking about standard functional algorithms that are parallelised for you, generic data structures for concurrent access, and that sort of good stuff.

Title: Modern programming language with intuitive concurrent programming abstractions

Body:
I am interested in learning concurrent programming, focusing on the application/user level (not system programming). I am looking for a modern high level programming language that provides intuitive abstractions for writing concurrent applications. I want to focus on languages that increase productivity and hide the complexity of concurrent programming.

To give some examples, I don't consider a good option writing multithreaded code in C, C++, or Java because IMHO my productivity is reduced and their programming model is not intuitive. On the other hand, languages that increase productivity and offer more intuitive abstractions such as Python and the multiprocessing module, Erlang, Clojure, Scala, etc. would be good options.

What would you recommend based on your experience and why?

EDIT: Thanks everybody for your interesting answers. It's hard to make a conclusion without actually trying since there are many good candidates: Erlang, Clojure, Scala, Groovy, and perhaps Haskell. I voted the answer with the most convincing arguments, but I'll try all the good candidates before deciding which one to pick :)


问:
How to teach your users/customers to send better error descriptions
I often have to deal with customers or users which are reporting errors in applications.
Most of the time their content is something useless as

ERROR!!!

x does not work

without much more information.

For resolving the issue I have to request every single detail of them, which often is more time consuming than fixing the issue itself. Other send information in formats which are not ideal, like screenshots (of data records, not of errors) although they could send a link (we have access to the systems) and so on.

How do you tell your users/customers to describe the problems with more details so that the whole process could be easier for both sides?

edit

This question is more about the social skills, than how to achieve programmatic collection of logs and error information. I'm aware of the fact that this should be part of good software design.

答:
Log everything you need. We have a rolling log file of x mb. If something bad happens, the user sends the logfile and often that's enough to fix a problem.

Another option is to use a remote desktop client to see for yourself what's wrong. These days that's as easy as letting the client download an exe.


问:
For what types of applications is Python a bad choice?
I just started learning Python, and I'd like to get some more context on the language.

I realize that, in many cases, Python is a slow language relative to C or C++.  Thus, Python is probably not the best choice for applications that need to run as quickly as possible.

Outside of this, it seems like Python is a great general purpose language that is easy to read and write.  The available libraries give it a huge amount of functionality.  Outside of performance critical applications, where is it a bad choice to use Python (and why)?

答: The two places that jump to mind are things that require a lot of concurrency, for which I would use Erlang. Or Heavy duty numeric computation, which I would probably try to use Fortran. </p>


答: Software aimed at embedded targets with their limited resources.  Most of the processors on this planet either cannot run Python due to insufficient resources, or nobody has ported a version to that architecture.  Most processors, even now, come with less than a megabyte of memory.</p>

Title: For what types of applications is Python a bad choice?

Body:
I just started learning Python, and I'd like to get some more context on the language.

I realize that, in many cases, Python is a slow language relative to C or C++.  Thus, Python is probably not the best choice for applications that need to run as quickly as possible.

Outside of this, it seems like Python is a great general purpose language that is easy to read and write.  The available libraries give it a huge amount of functionality.  Outside of performance critical applications, where is it a bad choice to use Python (and why)?


问:
Open source and updates
I have found an open source library that can work fine with my project,
but I have noted that It's not frequently updated and I'm afraid of not having the necessary support.

Is the frequency of updates a proper criterion for choosing an open source library rather than another?

答: The software in one of my products has not been updated for 18 months or so, primarily because across the 50000 or so instances where it is used there have not been any bug reports.  This is closed source software but I do not think that any of the users of the software are upset about the lack of updates.  In some cases performing an update is a logistical nightmare.</p>

Title: Open source and updates


答:
A simple rule of thumb is to create constants when you know you'll work with a fixed set of values which you know can be applied for any given context without needing to change; provide external configurations for everything else.

A good example of constants would be if all the shapes you worked with could either be SQUARE or ROUND. In most languages, you'll be able to leverage the fact that this value doesn't change over time, by allocating it only once and optimizing how it's accessed.

External configurations are necessary when you'll need to retrieve the value dynamically because you cannot assume in advance the value you'll be working with, but that doesn't mean you have to make any performance tradeoff: for configuration values you expect to be present, when done correctly, you only pay the price of retrieving them once and still get all the benefits.


问:
Where should we put External Libraries in our SVN?
We have the following SVN structure.

Projects: Our work

Clients: Projects for clients, needs to be different

Shared: Shared libraries we created

Docs: Documents explaining how software development flows within the company (has nothing to do with my question anyway)

Where should we put the external libraries? Let's say from opensource projects etc.

答:
Some people use Maven or similar solutions that automatically download libraries from various repositories as needed. It may be convenient, but then you're dependent on repositories maintained by some 3rd party. Getting some less popular libraries updated may be sluggish, and of course, most commercial libraries aren't available in public repositories.

We've simply put 3rd party libraries in our own repository under /lib/libraryname/tags/1.2.3/ and, using svn:externals, get those libraries to where they are needed. It may be a bit clumsy, some manual work is required to update the libraries, but at least your software is totally under your own control.

In technical sense, shared libraries are shared libraries regardless of who created them (you or someone else), so in your structure I would put them in /company/shared/3rdparty/etc.


问:
My Cassandra consultant left me and now I'm thinking about reverting to mysql
I run a middle size community and some time ago I started to develop social capabilities such as follow, status update, wall etc.

For some reason i thought that Cassandra was the right tool for the job so I looked online for a Cassandra developer and I found a very talented one.

Unluckily in the midst of the development the dev left (too much jobs) and so I'm here with a very nice class, a very nice demo, but a lot of fears that I won't be able to handle basic things such as compaction, scaling etc.

My biggest fear is to go online with all this coolness and then having a site inaccessible for hours or days.

The mysql consultant (very talented too) keeps saying me that I should stick with Mysql which I know rather well and in case something's wrong we can manage.

In that case I should take the class made for cassandra and abstract it for Mysql.

My question is this: Should I find another dev/consultant and stick with Cassandra because for social things it is definitely the best tool for the job, or should I listen to the Mysql consultant and revert to Mysql?

About 15k login each day
Average 20 actions per user
Avg 6 followers x user

(These are current statistics, but of course I'd like to increase them as much as possible.)

答:
I won't judge between MySQL and Cassandra for your situation. But it looks like you cannot find another talented Cassandra developer easily... So, unless you are doing experimental stuff and don't mind if it fails in production, go the safe way and continue with MySQL, you will have problems with MySQL as well as you will have problems with Cassandra but at least you will be able to manage them with MySQL.

If one day you cannot scale further with MySQL you will know exactly why and where the limits are, and at this moment you may choose another tool (Cassandra or not)...


问:
JSP Model 2 Architecture and Dependency Injection
If I'm writing a web application that uses the model 2 architecture, is it possible to use the Google Guice framework (or really any IoC container)? The reason I ask this question is because everything I've researched about DI, IoC, et cetera always uses Spring, Hibernate or some other framework/container in their examples. I'm just using Java classes, controllers, and JSP's to build this application and I can't find any good documentation about the subject. </p>

答: what you're looking for in the Java EE web tier is a technology called CDI, a tutorial on this can be found here</p>


答:
You are worried about the lack of updates but you don't tell us how long ago was this open source library published. Also, is it used by many users?

If its a new one, then yes the lack of updates would be disturbing but if its fairly mature then I don't think its a problem. Maybe nothing serious has been found.

If the code is on github or anything similar I would check the feature requests and the bug reports it has. Maybe send an email to the maintainer and ask him directly. He will be in a position to give you more information than any of us.

Title: Open source and updates

Body:
I have found an open source library that can work fine with my project,
but I have noted that It's not frequently updated and I'm afraid of not having the necessary support.

Is the frequency of updates a proper criterion for choosing an open source library rather than another?


答:
It can be, if you expect that the code you're reusing will often have defects that will cause defects in your application, and therefore have to be fixed. (Of course, you should thoroughly test the part of the library that you actually used and verify that it does the job correctly before you ship it with your product, but we all know the world isn't that tidy.) If this is the case you should not make commercial success dependent on third-party libraries where you are not sure about support - whether open-source or not!

But bear in mind that "few updates" and "likely to have defects" is not necessarily correlated. In fact, it may be anti-correlated for very wide-spread, very mature products. And of course, the bonus of open source is that if there is a defect with a clear and obvious fix, you can just make the fix without having to wait for external support at all.

Title: Open source and updates


答:
There's one fundamental problem about Continuous Integration (CI) that is perfectly mirrored in your question: CI practices are hard to implement and defend because CI server software is not trivial to setup, nor is it trivial to get your projects up and running through a CI server. With this, it becomes hard to actually see where's the gain in embracing CI at all.

First of all, CI is about insight and quality. Good CI brings you closer to your project, gives you proper feedback on quality metrics, documentation, coding standards compliance, etc. It should provide you with the tools to easily visualize all this, and allow you to at-a-glance recognize and easily associate a set of changes with a specific snapshot of all these project metrics.

It is not just about running unit tests. Not at all! Which brings me to quality. CI embraces errors, it does not avoid them or throw them away. What it does is quite simply provide you with a tool to error out early on, instead of later on. So you don't really commit previously tested code to a CI server. Although you should strive to commit clean and not broken code, you actually use the CI server to automatically run an integration builder automatically through your code and have it assess if everything came out right. If it has, neat! If it hasn't, no problem - good CI practices state that your next priority should just be to fix whatever has become broken. Which, in a good CI server, should be easily pointed out for you.

As a team's size increases, integration of everyone's code naturally becomes harder. It should be the task of a centralized CI server to test all integrated parts and take that burden off the team's members. So you must have everyone commiting early (and as cleanly as possible) and then monitoring builds status (there's usually notifications envolved). And again, if something gets broken because of some developer's commit, it immediatelly becomes his responsability to fix that and get those automated builds back to OK status immediately.

So you see, in my opinion every single project benefits from being Continuously Integrated. The thing is, until now and due to mind-boggling complexity from every single CI server I know of, people really fended off CI practices on smaller/simpler projects. Because, come on, people have better things to do than spending days configuring an ugly, overly-complex, under-delivering, bloated software.

I had this exact same problem, and that's what made me develop Cintient in my free time since about a year ago now. My premise was to make it simple to install, configure and use, and to make it deliver on those quality metrics that every one else pretty much fails or underdelivers. So, after this long answer comes my shameless plug of pointing out the GitHub link for the project (which is free and open-source, natch). It also has some nice screenshots, apparently. :-) https://github.com/matamouros/cintient

Hope I helped you.

(NOTE: Edited after Bryan Oakley's comment, on the fact that I should have taken more time to build a better answer. I also think he was right.)


答:
Since Python is a dynamically-typed language, without compile-time checking, refactoring a large Python project that doesn't have extensive unit tests will be difficult.

So if you have a large project that needs to be maintained and modified for a long time, and your team is not committed to creating automated tests for everything, then you may do better to use Java or C#.


问:
Is is possible to develop an application for both metro and classic style?
Is it possible to develop one application that can be be run in both: metro and classic style in Windows 8? I mean, application with the same core and two separate UIs, adjusted to currently used mode.</p>

答:
From what I've read and from the presentation I saw last night NO

Or at least not given the current tooling and support - as a for-example the Metro version of IE10 and the "desktop" version of IE10 are separate applications, they use the same rendering engine but they are distinct applications.

Further, delivery of Metro applications (again currently) has to be, let me emphasise that, is required to be via the marketplace (doubtless there will be corporate exceptions) - and the acceptance criteria for an app into the marketplace will preclude the code that would allow it to run on the desktop (one way or another).

Partly this is down to using WinRT instead of the current .NET framework - some sections of the library (including XAML) have been effectively moved into WinRT for Metro apps and the selection of the remaining System. libraries that you can use is constrained and partly this is down to want/expecting/requiring a certain standard of behaviour for Metro apps in order to maximise performance/battery life on tablet computers.

What you will be able to do, although I'm fuzzy on the details, is develop libraries that are portable between the two (at a source code level) as is already the case with some silverlight and phone code (you'll need to recompile not least because you will probably be changing dependencies from the System. to the Windows. namespace).

Edit: You can, in fact, develop "Portable Class Libraries" which is .DLL level compatibility but there are significant limitations on what namespaces are available to you - irritatingly (!) this will include interfaces/classes (like IObservable) that are used for view models in MVVM - which is one area where one might really like to share stuff (maximising common elements).

Is this ideal? That's a hard one - you can make a good argument either way (and its a safe bet that the windows team has chased this round and round in circles) but it does make sense, particularly in terms of moving the platform forward. I think how successful this is depends on how they make all of this work on large screen (lots of pixels!) and multi-monitor setups.


答:
For me a CI gets interesting if your team has more than 1 member.

You have to stop thinking of CI as "another PC running the tests for me". CI about having a defined and automated build process and release management.

CI is the single authoritative entity that creates your software release. If it doesn't build on the CI it just didn't happen.

With a CI you have restrictions to automate everything which will show you all the manual tweaks, hacks and shortcuts that you have in place and just don't work with a CI and should be avoided in the first place.

Problems it avoids:

Who is responsible for building the release

Is this person 24/7 available

But it builds on my machine syndrome

Removes all ambiguity about what was the version we released

Advantages (just too many to mention all):

Automated version numbering

Issue tracking integration

Automated metric generation

Static code analysis

Automated deployment

Multi-Stage setups


问:
Agile (scrum) and UML round-trip tools
How effective are automated round-trip tools for UML modeling? Do they help in coding quick, clean, efficient code? In what ways do these tools fit into the Agile methodology?</p>

答:
I think there is a confusion when talking of live code and model synchronization. It is not a good idea to permanently synchronize your model with your code. I still remeber Togethersoft which was the best round trip tool but it was so slow and if the UML editor was not open then your model was not updated if new classifiers creation at code level etc....

There is a new initiative which is a mix of round trip and code generation on demand with java code and model merge. The mechanism is based on mapping each java classifiers Id to a model element Id. I mean that you reverse first time the project and get a single model. It creates UML Id for each java classifiers and sub-elements which is related to java id. Once this job has been done you can model or code with UML eidtor. When you want to update you just select the merge option which will incrementally creates new classifiers added at code level with existing classifiers already created in your model. You can therefore have as many as needed iteration between code and model.

What I like with this Id approach mapping each java Id to UML id is that UML is now like a java editor and you can graphically change in 5 seconds what will be over 30mn at code level because everything is refactored immediately and model integrity check. It means if what you do is not correct you can immediately get a warning. It is just at model level therefore no other tool to install. Very simple just a click on Model check option.

What I also like is to create a model independent of my code. No tag in my java code because all model information is the UML model which is a single model. I then can just extract model views graphically. These views are built on a model representing the full application and updated on demand when model merge is selected.

This is why UML ids merge with java Ids make UML efficient, faster to write code but don't try to replace the code by using code generation templates. I mean that UML ids are done as if you were codding at graphical level and certainly not try to generate the code.

I would say that traditional UML with code generation templates is like when you try to create HTML page from a word document automatically. It certainly works well but then you are stuck and can not change anything. It is also horrible code HTML quality.
To avoid this problem of using code generation templates the UML ids to Java Ids merge make code the same as if hand codded. Really good quality.

Really very few UML initiative has been done on UML ids because the graphical layer is managing mapping (e.g. for example the GMF project used by Topcased or Papyrus) to the metamodel while it should be the model directly managing each UML and java ids working natively with no intermediate layers !!

Title: Agile (scrum) and UML round-trip tools


问:
"Worker object pool" pattern?
In my application requests are processed by objects of Processor-derived classes, something like CreateItemProcessor or MoveItemToGroupProcessor. Base Processor class implements most of common processing logic, and derived ones make some specific business logic related tasks.

An object of a certain processor type is created before request processing, and then wiped out afterward.

Eventually it came to a situation, when creation of a single processor object was taking major part of request processing time. So now I'm thinking about creation of a pool of request processor objects, and reuse them instead of using create/delete approach.

The problem here is that any single Processor object is not thread-safe, and actually shouldn't be tread-safe: it stores request-specific data inside. So my general approach to that is as follows:

Try to acquire 'processor' from a pool;

If there are no any available, wait;

When we have processor available, mark that as 'working' and start processing;

When job is done, "return" processor to the pool;

Notify pool that free processor is available.

Is there a kind of design pattern for that? Am I missing something from the existing GoF patterns? Any C#-related implementation details?

答:
I think you are talking about FlyWeight pattern: http://en.wikipedia.org/wiki/Flyweight_pattern
It is used in ThreadPool or database connection pools.

Regarding implementation - You can have a queue(s) of available processors. On request arrive you pop processor and return it back to the queue after completion. In this case your processor can be thread unsafe. There is a need to sync on queue access though.

Title: "Worker object pool" pattern?


问:
What's a good approach to adding debug code to your application when you want more info about what's going wrong?
When our application doesn't work the way we expect it to (e.g. throws exceptions etc.), I usually insert a lot of debug code at certain points in the application in order to get a better overview of what exactly is going on, what the values for certain objects are, to better trace where this error is triggered from. Then I send a new installer to the user(s) that are having the problem and if the problem is triggered again I look at the logs and see what they say.

But I don't want all this debug code to be in the production code, since this would create some really big debug files with information that is not always relevant.

The other problem is that our code base changes, and the next time, the same debug code might have to go in different parts of the application.

Questions

Is there a way to merge this debug code within the production code only when needed and have it appear at the correct points within the application?

Can it be done with a version control system like git so that all would be needed is a git merge?

P.S. The application I'm talking about now is .NET, written in C#.

答:
IMHO the best way is prevention, by logging all the necessary information within your exception messages. In the ideal case, this - together with the regular log messages - would be enough for you to reproduce the bug in your dev environment. But even in the less-than-ideal case, this should help you focus your investigation better, needing less extra debug logs to determine the exact root cause.

In the latter case, as others too suggested, you can minimize the disruption and performance penalty caused by superfluous log messages by setting log message levels carefully, and applying the appropriate log level threshold in production. I am not familiar with C# logging frameworks but in Java, all mainstream logging frameworks allow this, so I am pretty sure you can find similar solutions in the .Net world too.


答:
If you are only worried that the debug code will create big debug files you can still have it in production but disabled ( maybe with a global flag )

so when you want the user to turn it on have him change a config file or pass an argument to the executable.

Note: I am assuming you already have some debug code, if not I think Sardathrion's answer is the best.

Title: What's a good approach to adding debug code to your application when you want more info about what's going wrong?

Body:
When our application doesn't work the way we expect it to (e.g. throws exceptions etc.), I usually insert a lot of debug code at certain points in the application in order to get a better overview of what exactly is going on, what the values for certain objects are, to better trace where this error is triggered from. Then I send a new installer to the user(s) that are having the problem and if the problem is triggered again I look at the logs and see what they say.

But I don't want all this debug code to be in the production code, since this would create some really big debug files with information that is not always relevant.

The other problem is that our code base changes, and the next time, the same debug code might have to go in different parts of the application.

Questions

Is there a way to merge this debug code within the production code only when needed and have it appear at the correct points within the application?

Can it be done with a version control system like git so that all would be needed is a git merge?

P.S. The application I'm talking about now is .NET, written in C#.


答:
You could have a series of message via debug(), info(), trace() level of logging. Something like nlog will allow you to do that.  During production, you can set the level of logging and anything under what you want will be discarded. </p>

<p>Edit: I would suggest wrapping nlog under a class of your own and use that class.  That way, if you decide to change logger, just one class needs to change. </p>

Body:
You could have a series of message via debug(), info(), trace() level of logging. Something like nlog will allow you to do that.  During production, you can set the level of logging and anything under what you want will be discarded.

Edit: I would suggest wrapping nlog under a class of your own and use that class.  That way, if you decide to change logger, just one class needs to change.


答:
Yes there is, and it is named (rather unsurprisingly) Object Pool :-)

Googling for a C# implementation pops you up a StackOverflow thread in the first place.

Title: "Worker object pool" pattern?

Body:
In my application requests are processed by objects of Processor-derived classes, something like CreateItemProcessor or MoveItemToGroupProcessor. Base Processor class implements most of common processing logic, and derived ones make some specific business logic related tasks.

An object of a certain processor type is created before request processing, and then wiped out afterward.

Eventually it came to a situation, when creation of a single processor object was taking major part of request processing time. So now I'm thinking about creation of a pool of request processor objects, and reuse them instead of using create/delete approach.

The problem here is that any single Processor object is not thread-safe, and actually shouldn't be tread-safe: it stores request-specific data inside. So my general approach to that is as follows:

Try to acquire 'processor' from a pool;

If there are no any available, wait;

When we have processor available, mark that as 'working' and start processing;

When job is done, "return" processor to the pool;

Notify pool that free processor is available.

Is there a kind of design pattern for that? Am I missing something from the existing GoF patterns? Any C#-related implementation details?


答:
For the VCS side:

In case of Git you have to have two separate branches for clean and debug versions. Ordinary work happens in master, debugging - in debug branch (or bugfix branch, branched from debug) with added debug information.

During lifecycle you permanently merge changes from master to debug, thus - have two versions, which differ only in debug information amount. After bug-hunting you backmerge (from debug to master) only relevant part of changes from branch.

BTW: Mercurial with MQ require less frictions around branching-merging and use only one mainline branch, while allow to use insertions of debug code


答:
I fail to see how an UML round-trip synchronization tool would "help in coding quick, clean, efficient code".

Since we're talking agile practices, as far as TDD is concerned, what you often see (and it is promoted by people such as Bob Martin) is UML diagrams used merely as a sketching tool to flesh out the main classes before starting your TDD session. But these models more often than not prove totally wrong and become invalid as your code design incrementally emerges through the TDD process.

It's the TDD Refactor step combined with good coding practices that allows you to write "quick, clean, efficient code", not having ready-made UML diagrams and sticking to them while coding.

As for whether the UML models should be perfectly in sync with the code at any given time, I consider the benefits to be far less important than the cost. Unit tests are usually a better way of documenting the code IMO.

That's not to say higher level UML diagrams describing the architecture or use cases of the application aren't useful, though. But these are precisely too high-level to be used in round-trip generation.

Title: Agile (scrum) and UML round-trip tools

Body: How effective are automated round-trip tools for UML modeling? Do they help in coding quick, clean, efficient code? In what ways do these tools fit into the Agile methodology?</p>


问:
Avoiding bloated Domain Objects
We're trying to move data from our bloated Service layer into our Domain layer using a DDD approach. We currently have a lot of business logic in our services, which is spread out all over the place and doesn't benefit from inheritance.

We have a central Domain class which is the focus of most of our work - a Trade. The Trade object will know how to price itself, how to estimate risk, validate itself, etc. We can then replace conditionals with polymorphism. Eg: SimpleTrade will price itself one way, but ComplexTrade will price itself another.

However, we are worried that this will bloat the Trade class(s). It really should be in charge of its own processing but the class size is going to increase exponentially as more features are added.

So we have choices:

Put processing logic in Trade class. Processing logic is now polymorphic based on the type of the trade, but Trade class is now has multiple responsibilites (pricing, risk, etc) and is large

Put processing logic into other class such as TradePricingService. No longer polymorphic with the Trade inheritance tree, but classes are smaller and easier to test.

What would be the suggested approach?

答:
can't say much about your domain, but

We have a central Domain class which is the focus of most of our work - a Trade.

... it's a smell to me. I'd probably try to sketch the different responsibilities of the class and eventually decompose it to different aggregates. Aggregates would then be designed around roles and/or points of view of the stakeholders/domain experts involved.
If Price and Risk are involved in the same behavior/use case, they'd probably belong to the same aggregate. But if they're decoupled they maybe belong to separate aggregates.

Maybe RiskEvaluation might be a separate entity in your domain, eventually with a specific lifecycle (I can't really say, I am merely speculating ...you know your domain, I don't), but the key is to make implicit concepts explicit and to avoid coupling that's not driven by behavior, but only by legacy data coupling.

In general, I'd think about the expected behavior, and the different life cycles of the components involved. Just adding behavior on top of grouped data creates bloated objects. But the data has been grouped according do an existing data-driven design, so there's no need to stick to that.

OwnerDisplayName: djcredo

Title: Avoiding bloated Domain Objects


问:
Is it possible to develop a functional language based on PHP opcode?
Is it possible to develop a functional language based on PHP opcode?

Similar to Scala/bytecode or F#/CIL

Has somebody done this already?

答:
As PHP opcodes and the functional languages you listed are Turing Complete the answer is trivially, yes, it is possible. It may be more interesting though to ask if anyone has done this already.

After a bit of search on google and a few online code repositories there do seem to be people dabling in functional PHP http://www.sitepoint.com/the-state-of-functional-programming-in-php/ however I don't see anything approaching a new language implemented in opcodes.


答:
Instead of answering this question directly I will just tell you some ideas how that is done in ruby:

1) in a project root you have a one file, which has a list of libraries you would like to use with their version.
like

"popular lib1, version > 2.0" ,

"popular lib 2, version 1.55, store in www.aaa.bbb/1.55.tgz",

"popular lib 3, stored on www.xxx.com/1.git, any version"
So

2) the tool analyzes you version requirements and finds best version of libs (so all version requirements are matched).
so you have some sort of ./cache folder which contains copy of downloaded files.

So for a c# I would always copy whole libraries in the project root folder, like
libs3rdparty/ with name.    I dont like any sort of shared libraries per whole companies, with such a cheep disk space there is no sense in that. As an option ( to make SVN size smaller) you could create an install.bat file which takes lib versions from certain places and adds the libs3rdparty to the svnignore.

Title: Where should we put External Libraries in our SVN?

Body:
We have the following SVN structure.

Projects: Our work

Clients: Projects for clients, needs to be different

Shared: Shared libraries we created

Docs: Documents explaining how software development flows within the company (has nothing to do with my question anyway)

Where should we put the external libraries? Let's say from opensource projects etc.


答:
You can invest some time and add a 'Report a bug' red button in the top right corner of your app.  When a user presses the button try to take screen shot, collect all available logs for the session, (may be its worth to) open the direct screen sharing to the user screen , show him the simple form and automatically send data to your server.

-Try to ask a user as little as possible if your app can get data itself. Screen resolution, OS version, user name, login, last actions and logs

-Assign a ticket to a user and provide him a link, so he know that he has bug number 1234 on www.yoursite.issues/1234

-Ask a user what he tried to achieve.

I think this all together, or even partially, can help you to receive enough data and show the user that he can help you to make your software even better.

Title: How to teach your users/customers to send better error descriptions

Body:
I often have to deal with customers or users which are reporting errors in applications.
Most of the time their content is something useless as

ERROR!!!

x does not work

without much more information.

For resolving the issue I have to request every single detail of them, which often is more time consuming than fixing the issue itself. Other send information in formats which are not ideal, like screenshots (of data records, not of errors) although they could send a link (we have access to the systems) and so on.

How do you tell your users/customers to describe the problems with more details so that the whole process could be easier for both sides?

edit

This question is more about the social skills, than how to achieve programmatic collection of logs and error information. I'm aware of the fact that this should be part of good software design.


问:
Best free UML authoring tool
What free UML authoring tools do you use and why is it better than others?</p>

答: Although it's not exclusive to UML, I use Dia. It has the symbols used in most (if not all) of the UML diagrams, but it also supports flowcharts, network diagrams, and a few other things that I've occasionally used as a software engineer.

Title: Best free UML authoring tool

LastEditorDisplayName: Sergio


答:
As @jk. writes, since PHP opcode is Turing Complete it's definitely possible. But you should keep in mind that the Zend Engine is developed and optimized with only PHP in mind and it's not supposed to be a virtual machine that supports other languages. AFAIK no one has proposed building a new language for the Zend Engine, functional or not.

What you may find interesting though is the Parrot VM, which supports PHP (via Pipp) and a long list of other languages, including the nearly pure esoteric functional language Unlambda and Arc, a dialect of Lisp. On Parrot's functional support, Wikipedia tell us:

Parrot has rich support for several features of functional programming including closures and continuations, both of which can be particularly difficult to implement correctly and portably, especially in conjunction with exception handling and threading. Implementing solutions to these problems at the virtual machine level prevents repeated efforts to solve these problems in the individual client languages.

PHP does provide some functional concepts, like anonymous functions, but I don't think it would be practical to consider building a functional language on top of the Zend Engine.

Body:
Is it possible to develop a functional language based on PHP opcode?

Similar to Scala/bytecode or F#/CIL

Has somebody done this already?


问:
What is the difference between requirements and specifications?
I've been tasked with developing requirements and specifications for a project our group is starting.

I realized that I don't know the difference; a Google search just confused me more -- it seems some people say that specifications are requirements, but at a lower level.

答:
Requirements document what is needed - they shouldn't specify the how, but the what.

Specifications document how to achieve the requirements - they should specify the how.

In many places these documents are not separate and are used interchangeably.


答:
The sound-bite answer is that requirements are what your program should do, the specifications are how you plan to do it.

Another way to look at it is that the requirements represent the application from the perspective of the user, or the business as a whole. The specification represents the application from the perspective of the technical team. Specifications and requirements roughly communicate the same information, but to two completely different audiences.

Title: What is the difference between requirements and specifications?

Body:
I've been tasked with developing requirements and specifications for a project our group is starting.

I realized that I don't know the difference; a Google search just confused me more -- it seems some people say that specifications are requirements, but at a lower level.


答:
Perhaps the confusion is that I have heard specifications refer to Business Requirement Specification documents or IEEE standard SRS (Software Requirement Specification) documents.

IEEE standard SRS Template Example

I have also heard the term specifications refer more informally to Technical Specifications which explain design decisions and an implementation plan.

EDIT: I just noticed the link is incorrect... I will post a correct link shortly.


答:
Requirements:

Determine the needs or conditions to meet for a new or altered product, taking account of the possibly conflicting requirements of the various stakeholders.

Specifications:

They provide a precise idea of the problem to be solved so that they can efficiently design the system and estimate the cost of design alternatives. They provide guidance to testers for verification (qualification) of each technical requirement.

The quote is from "Systems Engineering Fundamentals*".

Requirements are based on stakeholders needs, specifications are more an inside detailed and technical document. They are different, but they talk about the same thing.

* Defense Acquisition University Press, 2001. PDF version of the text.


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

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

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

答:
Dual Monitors (I got that, yay me.)

Access to newsgroups (me no have
it:/)

Free coffee  (I got that, too, yay
me.)

Blackboard.

One or more bookshelves.

Laptop.

In-house training on software
engineering processes, tools, etc.

Ability to create your own "helper"
tools (if they help you get the job
done) in any language of your
linking (which is different from
using any language outside the official ones for developing the
main products you are getting paid
for.)

Part-time student assistance.


问:
When does the "Do One Thing" paradigm become harmful?
For the sake of argument here's a sample function that prints contents of a given file line-by-line.

Version 1:

```<code>void printFile(const string & filePath) {
  fstream file(filePath, ios::in);
  string line;
  while (std::getline(file, line)) {
    cout << line << endl;
  }
}
</code>```

I know it is recommended that functions do one thing at one level of abstraction. To me, though code above does pretty much one thing and is fairly atomic.

Some books (such as Robert C. Martin's Clean Code) seem to suggest breaking the above code into separate functions.

Version 2:

```<code>void printFile(const string & filePath) {
  fstream file(filePath, ios::in);
  printLines(file);
}

void printLines(fstream & file) {
  string line;
  while (std::getline(file, line)) {
    printLine(line);
  }
}

void printLine(const string & line) {
  cout << line << endl;
}
</code>```

I understand what they want to achieve (open file / read lines / print line), but isn't it a bit of overkill?

The original version is simple and in some sense already does one thing - prints a file.

The second version will lead to a large number of really small functions which may be far less legible than the first version.

Wouldn't it be, in this case, better to have the code at one place?

At which point does the "Do One Thing" paradigm become harmful?

答:
Short answer... it depends.

Think about this: what if, in the future, you won't want to print only to standard output, but to a file.

I know what YAGNI is, but I'm just saying there might be cases where some implementations are known to be needed, but postponed. So maybe the architect or whatever knows that function needs to be able to also print to a file, but doesn't want to do the implementation right now. So he creates this extra function so, in the future, you only need to change the output in one place. Makes sense?

If you however are certain you only need output in the console, it doesn't really make much sense. Writing a "wrapper" over cout << seems useless.

OwnerDisplayName: Petr

OwnerDisplayName: Luchian Grigore


答:
I personally prefer the latter approach, because it saves you work in the future and forces "how to do it in a generic way" mindset. Despite that in your case Version 1 is better than Version 2 - just because problems solved by Version 2 are too trivial and fstream-specific. I think it should be done the following way (including bug fix proposed by Nawaz):

Generic utility functions:

```<code>void printLine(ostream& output, const string & line) {
    output << line << endl;
}

void printLines(istream& input, ostream& output) {
    string line;
    while (getline(input, line)) {
        printLine(output, line);
    }
}
</code>```

Domain-specific function:

```<code>void printFile(const string & filePath, ostream& output = std::cout) {
    fstream file(filePath, ios::in);
    printLines(file, output);
}
</code>```

Now printLines and printLine can work not only with fstream, but with any stream.

Title: When does the "Do One Thing" paradigm become harmful?

Body:
For the sake of argument here's a sample function that prints contents of a given file line-by-line.

Version 1:

```<code>void printFile(const string & filePath) {
  fstream file(filePath, ios::in);
  string line;
  while (std::getline(file, line)) {
    cout << line << endl;
  }
}
</code>```

I know it is recommended that functions do one thing at one level of abstraction. To me, though code above does pretty much one thing and is fairly atomic.

Some books (such as Robert C. Martin's Clean Code) seem to suggest breaking the above code into separate functions.

Version 2:

```<code>void printFile(const string & filePath) {
  fstream file(filePath, ios::in);
  printLines(file);
}

void printLines(fstream & file) {
  string line;
  while (std::getline(file, line)) {
    printLine(line);
  }
}

void printLine(const string & line) {
  cout << line << endl;
}
</code>```

I understand what they want to achieve (open file / read lines / print line), but isn't it a bit of overkill?

The original version is simple and in some sense already does one thing - prints a file.

The second version will lead to a large number of really small functions which may be far less legible than the first version.

Wouldn't it be, in this case, better to have the code at one place?

At which point does the "Do One Thing" paradigm become harmful?

Body:
I personally prefer the latter approach, because it saves you work in the future and forces "how to do it in a generic way" mindset. Despite that in your case Version 1 is better than Version 2 - just because problems solved by Version 2 are too trivial and fstream-specific. I think it should be done the following way (including bug fix proposed by Nawaz):

Generic utility functions:

void printLine(ostream& output, const string & line) {
    output << line << endl;
}

void printLines(istream& input, ostream& output) {
    string line;
    while (getline(input, line)) {
        printLine(output, line);
    }
}

Domain-specific function:

void printFile(const string & filePath, ostream& output = std::cout) {
    fstream file(filePath, ios::in);
    printLines(file, output);
}

Now printLines and printLine can work not only with fstream, but with any stream.

OwnerDisplayName: gwiazdorrr


答:
Requirements are the users' description of what the finished product, in their eyes, should do.

Specification is the technical description of the solution in general, covering the requirements and much more - e.g. cost, technicalities, problems, etc.

Therefore, one of the main points is that the Requirements must come first before a Specification can be written.

(Notice the terminology - product and solution - the same thing but from different perspectives...)


问:
Which of these algorithms is best for my goal?
I have created a program that restricts the mouse to a certain region based on a black/white bitmap. The program is 100% functional as-is, but uses an inaccurate, albeit fast, algorithm for repositioning the mouse when it strays outside the area.

Currently, when the mouse moves outside the area, basically what happens is this:

A line is drawn between a pre-defined static point inside the region and the mouse's new position.

The point where that line intersects the edge of the allowed area is found.

The mouse is moved to that point.

This works, but only works perfectly for a perfect circle with the pre-defined point set in the exact center. Unfortunately, this will never be the case. The application will be used with a variety of rectangles and irregular, amorphous shapes. On such shapes, the point where the line drawn intersects the edge will usually not be the closest point on the shape to the mouse.

I need to create a new algorithm that finds the closest point to the mouse's new position on the edge of the allowed area. I have several ideas about this, but I am not sure of their validity, in that they may have far too much overhead.

While I am not asking for code, it might help to know that I am using Objective C / Cocoa, developing for OS X, as I feel the language being used might affect the efficiency of potential methods.

My ideas are:

Using a bit of trigonometry to project lines would work, but that would require some kind of intense algorithm to test every point on every line until it found the edge of the region... That seems too resource intensive since there could be something like 200 lines that would have each have to have as many as 200 pixels checked for black/white....

Using something like an A* pathing algorithm to find the shortest path to a black pixel; however, A* seems resource intensive, even though I could probably restrict it to only checking roughly in one direction. It also seems like it will take more time and effort than I have available to spend on this small portion of the much larger project I am working on, correct me if I am wrong and it would not be a significant amount of code (>100 lines or around there).

Mapping the border of the region before the application begins running the event tap loop. I think I could accomplish this by using my current line-based algorithm to find an edge point and then initiating an algorithm that checks all 8 pixels around that pixel, finds the next border pixel in one direction, and continues to do this until it comes back to the starting pixel. I could then store that data in an array to be used for the entire duration of the program, and have the mouse re-positioning method check the array for the closest pixel on the border to the mouse target position.

That last method would presumably execute it's initial border mapping fairly quickly. (It would only have to map between 2,000 and 8,000 pixels, which means 8,000 to 64,000 checked, and I could even permanently store the data to make launching faster.) However, I am uncertain as to how much overhead it would take to scan through that array for the shortest distance for every single mouse move event... I suppose there could be a shortcut to restrict the number of elements in the array that will be checked to a variable number starting with the intersecting point on the line (from my original algorithm), and raise/lower that number to experiment with the overhead/accuracy tradeoff.

Please let me know if I am over thinking this and there is an easier way that will work just fine, or which of these methods would be able to execute something like 30 times per second to keep mouse movement smooth, or if you have a better/faster method.

I've posted relevant parts of my code below for reference, and included an example of what the area might look like. (I check for color value against a loaded bitmap that is black/white.)

```<code>//
// This part of my code runs every single time the mouse moves.
//

CGPoint point = CGEventGetLocation(event);

float tX = point.x;
float tY = point.y;

if( is_in_area(tX,tY, mouse_mask)){

    // target is inside O.K. area, do nothing
}else{

CGPoint target;

//point inside restricted region:
float iX = 600; // inside x
float iY = 500; // inside y

// delta to midpoint between iX,iY and tX,tY
float dX;
float dY;

float accuracy = .5; //accuracy to loop until reached

do {
    dX = (tX-iX)/2;
    dY = (tY-iY)/2;

    if(is_in_area((tX-dX),(tY-dY),mouse_mask)){

        iX += dX;
        iY += dY;
    } else {

        tX -= dX;
        tY -= dY;
    }

} while (abs(dX)>accuracy || abs(dY)>accuracy);

    target = CGPointMake(roundf(tX), roundf(tY));
    CGDisplayMoveCursorToPoint(CGMainDisplayID(),target);

}
</code>```

Here is "is_in_area(int x, int y)" :

```<code>bool
is_in_area(NSInteger x, NSInteger y, NSBitmapImageRep *mouse_mask){

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    NSUInteger pixel[4];
    [mouse_mask getPixel:pixel atX:x y:y];

    if(pixel[0]!= 0){
        [pool release];
        return false;
    }
    [pool release];
    return true;
}
</code>```

答: What about to remember last point when the mouse was inside and cast rays to that point but also rotated by 1, 2, 4, 8, ... degrees to both sides? Then select the nearest point at the intersection of the egde if the result is too coarse, you can repeat the procedure to "fine-tune it", now starting with the nearest point found, not with the last inside position.</p>


答:
Have you looked into a logging framework like log4net (there are others too, but this seems to be the most popular for .NET)? I've used the Java equivalent, Log4J and it has the ability to log messages at different levels, such as Info, Warn, Error, Debug, Fatal. You can change the application's logging level through configuration rather then building it in. That way, you can normally run your application in production at the "Fatal" log-level, but on your workstation, run logging at "Warn" or "Debug" and no recompiling is necessary!

The only hard part is figuring out what level a logging message should be.


问:
What exactly is the build number in MAJOR.MINOR.BUILDNUMBER.REVISION
What I think about Build Numbers is that whenever a new nightly build is created, a new BUILDNUMBER is generated and assigned to that build. So for my 7.0 version application the nightly builds will be 7.0.1, 7.0.2 and so on. Is it so? Then what is the use of a REVISION after the build number? Or is the REVISION part being incremented after each nightly build? I am a little confused here... do we refer to each nightly build as a BUILD?

The format is mentioned here: AssemblyVersion - MSDN

答:
The last two digits are the total build number

1.01.2.1234

the build number is 2.1234 however most people will just use 1234 since the 2 part does not change frequently.


答:
Memory upgrade

because sometimes the model I'm building in my head just won't fit.

Title: Stuff every programmer needs while working

Body:
I've been tasked with creating a fun and relaxing environment, one thing I know that I want is ergonomic mice and keyboards, others have suggested exercise balls and bands.

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

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


答:
At this scale, it doesn't matter.  The single-function implementation is perfectly obvious and understandable.  However, adding just a bit more complexity makes it very attractive to split the iteration from the action.  For example, suppose you needed to print lines from a set of files specified by a pattern like "*.txt".  Then I would separate the iteration from the action:

```<code>printLines(FileSet files) {
   files.each({
       file -> file.eachLine({
           line -> printLine(line);
       })
   })
}
</code>```

Now the file iteration can be separately tested.

I split functions to either simplify testing, or to improve readability.  If the action performed on each line of data were complex enough to warrant a comment, then I would certainly split it into a separate function.

Body:
At this scale, it doesn't matter.  The single-function implementation is perfectly obvious and understandable.  However, adding just a bit more complexity makes it very attractive to split the iteration from the action.  For example, suppose you needed to print lines from a set of files specified by a pattern like "*.txt".  Then I would separate the iteration from the action:

printLines(FileSet files) {
   files.each({
       file -> file.eachLine({
           line -> printLine(line);
       })
   })
}

Now the file iteration can be separately tested.

I split functions to either simplify testing, or to improve readability.  If the action performed on each line of data were complex enough to warrant a comment, then I would certainly split it into a separate function.


答: Our team uses the third number (revision) as the revision number from the Subversion repository.  We use the fourth number (build) as the build number from our TeamCity continuous integration server which actually creates the build.  TeamCity creates a new AssemblyInfo file with the right #s in it during the build process.</p>

Title: What exactly is the build number in MAJOR.MINOR.BUILDNUMBER.REVISION

Body:
What I think about Build Numbers is that whenever a new nightly build is created, a new BUILDNUMBER is generated and assigned to that build. So for my 7.0 version application the nightly builds will be 7.0.1, 7.0.2 and so on. Is it so? Then what is the use of a REVISION after the build number? Or is the REVISION part being incremented after each nightly build? I am a little confused here... do we refer to each nightly build as a BUILD?

The format is mentioned here: AssemblyVersion - MSDN


问:
Getting solutions off the internet. Bad or Good?
I was looking on the internet for common interview questions. I came upon one that was about finding the occurrences of certain characters in an array. The solution written right below it was in my opinion very elegant. But then another thought came to my mind that, this solution is way better than what came to my mind. So even though I know the solution (that most probably someone with a better IQ had provided) my IQ was still the same. So that means that even though i may know the answer, it still wasn't mine. hence if that question was asked and i was hired upon my answer to that question i couldn't reproduce that same elegance in my other ventures within the organization

My question is what do you guys think about such "borrowed intelligence"? Is it good? Do you feel that if solutions are found off the internet, it makes you think in that same more elegant way?

答:
I don't think it's so terrible, as long as you understand the solution and are able to explain it and adapt it to new situations. And you worry that you weren't as "elegant"? Now you've seen a better example of "elegance" and you can learn from this how to be more elegant.

In general, I think it's pretty unreasonable to ask everyone to rediscover everything on their own - there just isn't time for that. In fact, if someone insisted on rediscovering everything rather than just learn from existing solutions online, I'd probably be less inclined to hire them.


答:
I'll ask you a question, Do you usually work of your own knowledge or do you query the web to expand your knowledge and solve a problem better than you could on your own? Or perhaps you reference a book. </p>

<p>"Borrowing" knowledge as you put it is nothing more that doing research in order to improve on your best solution. I would argue that is actually a good thing.</p>

Title: Getting solutions off the internet. Bad or Good?

Body:
I was looking on the internet for common interview questions. I came upon one that was about finding the occurrences of certain characters in an array. The solution written right below it was in my opinion very elegant. But then another thought came to my mind that, this solution is way better than what came to my mind. So even though I know the solution (that most probably someone with a better IQ had provided) my IQ was still the same. So that means that even though i may know the answer, it still wasn't mine. hence if that question was asked and i was hired upon my answer to that question i couldn't reproduce that same elegance in my other ventures within the organization

My question is what do you guys think about such "borrowed intelligence"? Is it good? Do you feel that if solutions are found off the internet, it makes you think in that same more elegant way?

Body:
I'll ask you a question, Do you usually work of your own knowledge or do you query the web to expand your knowledge and solve a problem better than you could on your own? Or perhaps you reference a book.

"Borrowing" knowledge as you put it is nothing more that doing research in order to improve on your best solution. I would argue that is actually a good thing.


问:
Unix as opposed to Windows (Java and C++)
Firstly I should explain the background. I am interested in high frequency trading programming roles. After looking at many job specs it is very clear that there is a big demand for programmers who have programmed Java and C++ on Unix as opposed to Windows.

My question is what are the differences a High Freq programmer would come across? It cannot be something in the language itself because syntactically they do not differ over OS? Therefore I thought it must be something which the programming language has to interface, resources etc?

Could anyone please help me out as I am trying to improve my C++/Java on Unix, in order to aim for this type of career?

ps I'm guessing part of this answer lies with the socket infrastructure on Unix?

答:
I worked at a HF shop and another services company for a short time. They care about speed. Speed of the software, speed of the network, and any other thing that could possibly have to do with speed.

They use Linux for stability, as other people have noted, but also because it allows you to tune, measure, and control almost everything. With a multicore box, you can use the program 'taskset' to keep your process on a dedicated CPU, for example. But most fundamentally, Linux lets you modify, control, and even edit the kernel of the OS.  So say you get an exchange message that is only 1kb. You can control the ethernet driver to trigger an interrupt as soon as that tiny bit of data comes thru, whereas the default may be to wait for more data. HF shops care about this for latency.

Programming wise, learn everything you can about C++, including templates. Learn how to speed programs up any way you can. Learn about 'locality of reference' to keep data nearby in memory so it stays in cache instead of getting paged out. Learn about assembly, so you can see that one line of C++ produces X asm instructions, but another line produces X-1. Learn about threads and processes, and how the kernel controls process scheduling ( there are different ways to control it ).

Java is different, but I don't know enough to give you any advice. What I've heard about it is to learn how to keep code blocks in cache and it will run as fast as C++. Learn everything you can about making Java run fast and the different java VM's available on Linux.

So Linux is like a kit car, and Windows is like a car off GM's assembly line. Windows is one-size-fits-all, and you wont' get any inside details without shelling out $ to Microsoft. Then the added uncertainty of whether the next version of stuxnet could come thru and compromise your whole network. Or next year they'll change the API and you have to learn it all over again. Linux is solid and changes very little.

Hope this helps.


答:
Having a function do only "one thing" is a means to two desirable ends, not a commandment from God:

If your function only does "one thing", it will help you avoid code duplication and API bloat because you'll be able to compose functions to get more complex things done instead of having a combinatorial explosion of higher-level, less-composable functions.

Having functions only do "one thing" may make the code more readable.  This depends on whether you gain more clarity and ease of reasoning by decoupling things than you lose to the verbosity, indirection and conceptual overhead of the constructs that allow you to decouple things.

Therefore, "one thing" is unavoidably subjective and depends on what level of abstraction is relevant to your program.  If printLines is thought of as a single, fundamental operation and the only way of printing lines that you care about or foresee caring about, then for your purposes printLines only does one thing.  Unless you find the second version more readable (I don't) the first version is fine.

If you start needing more control over lower levels of abstraction and ending up with subtle duplication and combinatorial explosion (i.e. a printLines for filenames and a completely separate printLines for fstream objects, a printLines for console and a printLines for files) then printLines is doing more than one thing at the level of abstraction you care about.


问:
Interviewing someone for general unix skills
How would you test a developer that claims to have *nix shell experience (just to be clear, we don't want to test if someone can develop on *nix, only that they know their way around the command line).

I was thinking about making them solve a problem of getting information out of log files, which would involve some basics like cat, grep, cut, ... combined with piping.

What other basic knowledge would you ask for? Once again, this isn't for interviewing someone who will develop for *nix systems, and also not for *nix system admins, but just for regular developers that sometimes need to do some work on a *nix system.

答:
why make them write a functional program ? what's wrong with saying "tell me the difference between grep and sed, or what does X command do ? etc . that way, you can lead them around a little.

if they fumble on the specific assignment you give them, you might not think they're smart. but if you ask general questions, you give them the chance to show you what they do know, which may be substantial but in a different way than what you were wondering.