答:
Linux distributions (as well, I think, as BSD-flavoured Unices) have a user-friendly interface to program installation, via so-called package managers (or ports management in the BSD case): pacman for Arch, dpkg for Debian/Ubuntu, and so on.

These package manager provide a way to install programs by means of uniform configuration files. Once the program you need is packaged according to your distro's package manager you can simply run its install command over the selected package (with occasional user-specific customizations, though often none at all) and the manager does the rest.

Package managers are usually more user-friendly than Windows' program-specific installer processes, just for the uniform way programs are packaged for installation. They usually also allow you to query the package manager database for the program you're looking for, see its dependencies.

They also support centralized update of the packages.


问:
Best approach for multilingual Java Enum
I'm running into issues with an approach I am taking and am now wondering if I just started down the wrong path and should rethink my approach.  Here is what I attempting.

I would like to use an Enum to represent different possible Account Statuses (there are other finite data sets that I will be setting up using a duplicate approach):

A, Active

I, Inactive

P, Pending

Those Account Statuses must be presented to the user in their language if preference.

Example: Account Status is A, show it as Active for English speakers and Activo for Spanish.

There are also situations where I would like to show a dropdown list of all possible Account Statuses in the appropriate locale preference.

Current Approach

Use an AccountStatusEnum class with values of (A,I,P).

In a private static member variable store an EnumMap of localized Account Statuses inside a EnumMap of possible Locales.

Example:

```<code>private static EnumMap<LocaleEnum, EnumMap<AccountStatusEnum, String>> localeAccountStatuses = new EnumMap<LocaleEnum, EnumMap<AccountStatusEnum, String>>(LocaleEnum.class);
</code>```

This would get loaded within a static initialization block.

I could then use the following methods to get all the values for a dropdown:

```<code>public static EnumMap<AccountStatusEnum, String> getAccountStatuses(LocaleEnum locale) {
        return localeAccountStatuses.get(locale);
    }
</code>```

Or I could use this method to get a single description for a given Enum:

```<code>public String getDescription(LocaleEnum locale){
            return getAccountStatuses(locale).get(this);
        }
</code>```

Example Usage: AccountStatusEnum.A.getDescription(LocaleEnum.es_MX);

I'm curious about your thoughts on this approach and possible better approaches for accomplishing the same thing.

EDIT
The logic to get the values to populate the Enums would be centralized within a single helper class.  Therefore if the source of the descriptions changes to come from a new source, the code change is minimized.

Thanks

答:
ResourceBundle is the way to go, but I would take advantage of the fact that enums are objects, and hide the details of i19n inside

```<code>public enum MyEnum {
  A,
  I,
  P;

  private String localeText = null;

  private MyEnum() {
    // Load resource bundle
    this.localeText = // get message;
  }

  public String getLocaleText() {
    return this.localeText();
  }
}
</code>```

That would allow you to do:

```<code>MyEnum.A.getLocaleText();
</code>```

directly, everywhere

An optimization would be loading the resource bundle as an static attribute, in an static initializer.

And in JEE, bonus points for making the resource bundle injectable (so you may change the localization strings easily).

ContentLicense: CC BY-SA 3.0

Body:
ResourceBundle is the way to go, but I would take advantage of the fact that enums are objects, and hide the details of i19n inside

public enum MyEnum {
  A,
  I,
  P;

  private String localeText = null;

  private MyEnum() {
    // Load resource bundle
    this.localeText = // get message;
  }

  public String getLocaleText() {
    return this.localeText();
  }
}

That would allow you to do:

MyEnum.A.getLocaleText();

directly, everywhere

An optimization would be loading the resource bundle as an static attribute, in an static initializer.

And in JEE, bonus points for making the resource bundle injectable (so you may change the localization strings easily).


问:
Why does changing from one language to another make a programmer fresher?
Right now I have been working on language X for the last 2 years. I am very good at it, but language X is not popular so jobs are not readily available for it. Consequently, I am thinking to change from language X to language Y. But that means I'll be a fresher again. Is making the change worth it? Even if it means losing all the experience I have in the other language? </p>

答:
I'd question why you are taking this perspective.  Learning a new language and advancing how things are done is par for the course, in my opinion.  Your experience with language X can still be quite valuable as some of what you learned is probably transferable as things like problem solving may still use some of the same steps,e.g. figuring out what is cause of the issue and knowing how to use various resources around you, which can still be worth something.

While there may be a change in salary, it isn't the end of the world is it?

ContentLicense: CC BY-SA 2.5


问:
Why don't developers make installation wizards on linux?
I'm sure it's not about laziness or anything like that but I fail to understand why developers of even mainly consumer facing apps don't make any sort of installation wizard where you go next-next-finish. The same apps usually have installers for Windows and Mac OS so why not Linux?

Is there any technical reason for this trend or is it just convention?

EDIT (23-09-2014):
This question was not asked to start a Windows vs Linux flame war. I have used all 3 major operating systems and apart from Linux, the other two (Windows and Mac OS) both have installers. I have not installed Oracle yet but whatever I have needed to install, I never saw any GUI installer for Linux.

Yes, I know that Linux has package managers so the developers don't "need" to make the installers. But there is still a huge amount of software that is either outdated in the default package managers, or simply not available. Plus, since Linux is sold as an alternative to Windows for casual users (Ubuntu is trying hard in this domain), it would make much more sense to just give the users what they are familiar with.

Take for example, setting up a LAMP stack. Those are all open-source software in the default repositories, but can you set-up everything in one go without a script? Now look at the WAMP server in Windows. You just run an installer and it installs multiple software in such a way that they work well with each other. Then it sets up good defaults and stuff. Installers can do that, package managers don't. Yes, you can find a script for that online, but where? And which one?

Installers aren't some obsolete technology from the past. They are still useful, and 95% users are already comfortable with them.

答: Because they don't need to. Linux distributions usually have working package management systems, unlike Windows, where every single application has to re-implement installation and updating over and over and over and over again.</p>


问:
Organizations of user stories and tasks
I have bought Jira for my hobby project and I am currently creating epics, user stories and tasks. I have a question regarding organization and registration of tasks.

1)

I have a user story that is: "As a candidate I want to see which services I have access to". Tasks belonging to this user story is:

Create service for listing all services that a candidate have access to

Create SQL-script

Create models for database tables

Create a service for returning detailed information about a service

2)

I have another user story that is: "As a buyer I want to see which services that I can buy". And the tasks are:

Create service for listing all services that is available

Create a service for returning detailed information about a service

...

The thing that doesn't feel right is the task: "Create a service for returning detailed information about a service". It is duplicated because I don't know how to handle/what to do when a task applies to multiple user stories? Is it normal to only have that task in the first user story that will be done first? It is a requirement for both user stories, but I can use the same service for both if you understand what I mean?

答:
Yes it's normal, because you've already finished the task. You estimated some time for that task and you worked on that task. So that makes it perfectly normal to skip that task for other stories that have the same task.

If you want (for history purpose) you could write that task again for the other story and put 0 in estimated time, just so you know you've finished it. Then you can keep track of what you had to do to finish that story.

Title: Organizations of user stories and tasks


答:
The target audience is different. Unix, and Unix-like systems, were usually used by professional programmers, sysadmins, engineers and serious hobbyists who customized each system to their needs. Any "installation wizards" would only limit their choices instead of giving access to all the variables they need. And the ones now out there still do.

Windows is not targeted at professionals in the same way and, thus, has more general purpose installers geared toward "users" who only want the thing installed. Linux is garnering more of these user-types who would probably appreciate such a thing but, possibly, most distros still have the professional in mind.

Title: Why don't developers make installation wizards on linux?

Body:
I'm sure it's not about laziness or anything like that but I fail to understand why developers of even mainly consumer facing apps don't make any sort of installation wizard where you go next-next-finish. The same apps usually have installers for Windows and Mac OS so why not Linux?

Is there any technical reason for this trend or is it just convention?

EDIT (23-09-2014):
This question was not asked to start a Windows vs Linux flame war. I have used all 3 major operating systems and apart from Linux, the other two (Windows and Mac OS) both have installers. I have not installed Oracle yet but whatever I have needed to install, I never saw any GUI installer for Linux.

Yes, I know that Linux has package managers so the developers don't "need" to make the installers. But there is still a huge amount of software that is either outdated in the default package managers, or simply not available. Plus, since Linux is sold as an alternative to Windows for casual users (Ubuntu is trying hard in this domain), it would make much more sense to just give the users what they are familiar with.

Take for example, setting up a LAMP stack. Those are all open-source software in the default repositories, but can you set-up everything in one go without a script? Now look at the WAMP server in Windows. You just run an installer and it installs multiple software in such a way that they work well with each other. Then it sets up good defaults and stuff. Installers can do that, package managers don't. Yes, you can find a script for that online, but where? And which one?

Installers aren't some obsolete technology from the past. They are still useful, and 95% users are already comfortable with them.


问:
How to express what do do when error occurs in a user story?
How do you express what to do when error occurs in a user story? Should the response to what happen on errors be in a task of the original user story, or should I create another user story that is concerned with what happens on errors?

E.g.

This says nothing about what to do on errors such as credit card is invalid, not enough money, …

As a buyer I want to pay for the order with a credit card to get immediately access to the services.

I could add another user story like this:

As a buyer I want to get information about errors during payment immediately so that I can fix the errors and try again.

Which of these is common/correct? Should the error handling be part of the original user story?

答: No, you should just create one user story with WHAT the user wants and what is his goal. The user doesn't care about errors, so it shouldn't be a part of the story. But you should always estimate time for error handling, because it takes time and you would want that time to show up in your burndown chart.</p>


答:
I've always considered user stories as documented requirements and tasks as implementation plans or hints.

It is very likely that two or more requirements will end up reusing the same code or infrastructure.  This is why it's possible for two user stories to require the same tasks.

In order to get around this, I typically won't specify my tasks until right before my sprint begins.  This means I'm specifying an implementation plan according to the current state of the project.  If my story depends on a Service X that isn't yet implemented, then I'll add a task for that.  If, however, I managed to squeeze in Service X in my last sprint, then there's no need to write a duplicate task for it.

If, on the other hand, you specify your story tasks far in advance, then it's hard to tell what will already be implemented by the time you pick up a story.  And that makes it hard to determine which tasks specify.

Title: Organizations of user stories and tasks

Body:
I have bought Jira for my hobby project and I am currently creating epics, user stories and tasks. I have a question regarding organization and registration of tasks.

1)

I have a user story that is: "As a candidate I want to see which services I have access to". Tasks belonging to this user story is:

Create service for listing all services that a candidate have access to

Create SQL-script

Create models for database tables

Create a service for returning detailed information about a service

2)

I have another user story that is: "As a buyer I want to see which services that I can buy". And the tasks are:

Create service for listing all services that is available

Create a service for returning detailed information about a service

...

The thing that doesn't feel right is the task: "Create a service for returning detailed information about a service". It is duplicated because I don't know how to handle/what to do when a task applies to multiple user stories? Is it normal to only have that task in the first user story that will be done first? It is a requirement for both user stories, but I can use the same service for both if you understand what I mean?


问:
What do Java developers think of Scala?
I've noted that IDE support is nowhere near as good, but the language itself supports functional programming idioms much more cleanly.</p>

答:
I like Scala for many reasons, but there is one that is often overlooked: its simplicity.

Scala might not be as simple as, say, Oberon, but it is quite a lot simpler than some other languages. The Scala Language Specification is ~160 pages, the Java Language Specification is ~600 (just the language, not the JVM or the libraries!), the ECMA-334 C# Language Specification (which AFAIK corresponds to a subset of Visual C# 2.0) is ~440 pages (this is without stuff like LINQ query comprehensions, lambda expressions, extension methods, generic co- and contravariance, dynamic, optional arguments with default values, keyword arguments, var). Even the current draft for ECMAScript 5.1 is bigger at ~210 pages. And of course my own "default" language, Ruby, whose current ISO Draft weighs in at ~310 pages, which only specify an almost unusably tiny subset of the intersection of Ruby 1.8.6, 1.9.1 and 1.9.2.

Title: What do Java developers think of Scala?


答:
You'll get a lot a conflicting opinions on this one.

I typically like to specify happy-path behaviour and error behaviour in a single story unless that suddenly makes the story too large to work on.  If error behaviour is complex then it should be its own story.

My favourite way of clearly specifying what is expected in a story (just happy-path, or error-path as well?) is by using Acceptance Criteria.

I don't consider a story to be implemented until all its Acceptance Criteria have been implemented.

In the case of your example, these could be:

```<code>Given I'm at the payment page,
When I pay with a Credit Card,
And the payment is accepted,
Then I expect access to the Services

Given I'm at the payment page,
When I pay with a Credit Card,
And the payment is declined
Then I expect a payment declined message
</code>```

Title: How to express what do do when error occurs in a user story?

Body:
How do you express what to do when error occurs in a user story? Should the response to what happen on errors be in a task of the original user story, or should I create another user story that is concerned with what happens on errors?

E.g.

This says nothing about what to do on errors such as credit card is invalid, not enough money, …

As a buyer I want to pay for the order with a credit card to get immediately access to the services.

I could add another user story like this:

As a buyer I want to get information about errors during payment immediately so that I can fix the errors and try again.

Which of these is common/correct? Should the error handling be part of the original user story?

Body:
You'll get a lot a conflicting opinions on this one.

I typically like to specify happy-path behaviour and error behaviour in a single story unless that suddenly makes the story too large to work on.  If error behaviour is complex then it should be its own story.

My favourite way of clearly specifying what is expected in a story (just happy-path, or error-path as well?) is by using Acceptance Criteria.

I don't consider a story to be implemented until all its Acceptance Criteria have been implemented.

In the case of your example, these could be:

Given I'm at the payment page,
When I pay with a Credit Card,
And the payment is accepted,
Then I expect access to the Services

Given I'm at the payment page,
When I pay with a Credit Card,
And the payment is declined
Then I expect a payment declined message


问:
How to securely implement roles in a Windows Form application?
As an ISV, what is considered best practice for implementing application role based security? In other words, only allow users to access certain features in the application based on what roles they belong to.

We currently just use a table in our database to store this, but it has been suggested that for maximum HIPAA compliance, this isn't secure enough.

My first thought was to just use Active Directory groups, as it would seem that is what they are designed for, however, it just doesn't seem practical to rely on our clients IT departments to create groups and assign users to them for groups that are specific only to our application. This can't be best practice for ISVs...

At this point it my research, it seems that possibly the best solution might be to use something like Active Directory Application Mode (ADAM) (Active Directory Lightweight Directory Services) and possibly AzMan (Windows Authorization Manager)?

Again, this is for a Windows Forms application, not a Web application or in an "in house" solution.

If it matters, we are also in the process of transitioning our home-baked authentication to instead use active directory for authentication.

Also of note is this needs to be secure (HIPAA compliant).

All the information I can find on these subjects seems to be for developing applications for in house use, or for web applications, and neither of these approaches feels appropriate for a Windows Forms application.

(We are using .NET for development.)

答:
The Solution can be implemented in following method. The required screens in the application would be.

User Group Master - Create Multiple groups from the screen

User Master - create multiple users from the screen

User Group Detials Master - Select User, the screen would list different user group. Assign different groups to the user.

User Group Rights Master - Select the Group, List different menus in the application and grant different privilages.

Method For Implementation

Assign Menu ID to all Menus, Keep a menu master table to list in screen for assigning rights.

Create a rights details table with menu id,group id and different rights you want to control,visibility,save,editing details and additional stuffs based on your requrements.

Create a function checkpermission while doing any operations in the screen or accessing the menu item with the menu id and the permission to check and user id as parameter. The function will return value True or False and the rights can be controlled.

The same can be achieved in Web Application also. It has been implemented succesfully in various personal projects which I had undertaken.
Additionaly you could also have an Audit log insert in the permission checking function and provide access reports based on screen accessed or data modified on screen or task completed on screen or additional task you would want logged in your application

Alternatively, Coupled with the Same you can generate and ldap Authentication function using active directory services. With this you
  will be able to log on to the System only when the user logs in from
  the specified domain set by the IT Administrator group.

You can also find a sample code for the same and can develop based on the same.

```<code>using System.Text;
using System.Collections;
using System.DirectoryServices;
using System;
using System.DirectoryServices.AccountManagement;
using System.ServiceModel;namespace ClassLibrary
{
    public class LdapAuthentication
    {
        #region Variables/Constructor
        private string _path;
        private string _filterAttribute;

        public LdapAuthentication(string path)
        {
            //to initialize the Active Directory path
            _path = path;
        }
        #endregion

        #region User Authentication
        public bool IsAuthenticated(string domain, string username, string pwd)
        {
 #region Active Directory Direct Connection
            //accepts a domain name, user name and password as parameters and returns bool to indicate whether or not the user with
            //a matching password exists within Active Directory. The method initially attempts to bind to Active Directory using the
            //supplied credentials. If this is successful, the method uses the DirectorySearcher managed class to search for the
            //specified user object. If located, the _path member is updated to point to the user object and the _filterAttribute member
            //is updated with the common name attribute of the user object

            string domainAndUsername = domain + @"\" + username;
            DirectoryEntry entry = new DirectoryEntry(_path,  domainAndUsername, pwd);
            try
            {
                // Bind to the native AdsObject to force authentication.
                Object obj = entry.NativeObject;
                DirectorySearcher search = new DirectorySearcher(entry);
                search.Filter = "(SAMAccountName=" + username + ")";
                search.PropertiesToLoad.Add("CN");
                SearchResult result = search.FindOne();
                if (null == result)
                {
                    return false;
                }
                // Update the new path to the user in the directory
                _path = result.Path;
                _filterAttribute = (String)result.Properties["cn"][0];
            }
            catch (Exception ex)
            {
                throw new Exception("Error authenticating user. " + ex.Message);
            }
            return true;

            #endregion
        }
        #endregion
}
}
</code>```

Body:
The Solution can be implemented in following method. The required screens in the application would be.

User Group Master - Create Multiple groups from the screen

User Master - create multiple users from the screen

User Group Detials Master - Select User, the screen would list different user group. Assign different groups to the user.

User Group Rights Master - Select the Group, List different menus in the application and grant different privilages.

Method For Implementation

Assign Menu ID to all Menus, Keep a menu master table to list in screen for assigning rights.

Create a rights details table with menu id,group id and different rights you want to control,visibility,save,editing details and additional stuffs based on your requrements.

Create a function checkpermission while doing any operations in the screen or accessing the menu item with the menu id and the permission to check and user id as parameter. The function will return value True or False and the rights can be controlled.

The same can be achieved in Web Application also. It has been implemented succesfully in various personal projects which I had undertaken.
Additionaly you could also have an Audit log insert in the permission checking function and provide access reports based on screen accessed or data modified on screen or task completed on screen or additional task you would want logged in your application

Alternatively, Coupled with the Same you can generate and ldap Authentication function using active directory services. With this you
  will be able to log on to the System only when the user logs in from
  the specified domain set by the IT Administrator group.

You can also find a sample code for the same and can develop based on the same.

using System.Text;
using System.Collections;
using System.DirectoryServices;
using System;
using System.DirectoryServices.AccountManagement;
using System.ServiceModel;namespace ClassLibrary
{
    public class LdapAuthentication
    {
        #region Variables/Constructor
        private string _path;
        private string _filterAttribute;

        public LdapAuthentication(string path)
        {
            //to initialize the Active Directory path
            _path = path;
        }
        #endregion

        #region User Authentication
        public bool IsAuthenticated(string domain, string username, string pwd)
        {
 #region Active Directory Direct Connection
            //accepts a domain name, user name and password as parameters and returns bool to indicate whether or not the user with
            //a matching password exists within Active Directory. The method initially attempts to bind to Active Directory using the
            //supplied credentials. If this is successful, the method uses the DirectorySearcher managed class to search for the
            //specified user object. If located, the _path member is updated to point to the user object and the _filterAttribute member
            //is updated with the common name attribute of the user object

            string domainAndUsername = domain + @"\" + username;
            DirectoryEntry entry = new DirectoryEntry(_path,  domainAndUsername, pwd);
            try
            {
                // Bind to the native AdsObject to force authentication.
                Object obj = entry.NativeObject;
                DirectorySearcher search = new DirectorySearcher(entry);
                search.Filter = "(SAMAccountName=" + username + ")";
                search.PropertiesToLoad.Add("CN");
                SearchResult result = search.FindOne();
                if (null == result)
                {
                    return false;
                }
                // Update the new path to the user in the directory
                _path = result.Path;
                _filterAttribute = (String)result.Properties["cn"][0];
            }
            catch (Exception ex)
            {
                throw new Exception("Error authenticating user. " + ex.Message);
            }
            return true;

            #endregion
        }
        #endregion
}
}


答:
To large extends it's both. The Linux distribution model is closer to AppStore/Play Store then traditional Windows/Mac OS X one - and even those platform are moving there from what I've heard.

The convention is that it's simpler. Most arguments for the AppStore/Play Store applies to Linux as well:

Automatic updates. Having 20 programs update separately on Windows is disruptive and inefficient. User needs click though Java/Flash/Adobe/... updates on boot.

Single, trusted, repository. Do you check if you download via secure connection? Or you haven't download from an Reader update from get.adobe.com.hackers.example.com/setup.exe? Even if you do most users, especially not power users, don't. Instead you go to software centre or similar program in Linux and get a trusted copy.

Furthermore there are following benefits, which may not apply to AppStore/Play Store:

Not every Linux has GUI - think http server - yet most distros supports such configuration. Ok. Not everyone needs one but sooner or later someone will want to use it for whatever reason.

The ABIs of libraries on various distros may differ. Not going into details having an installer would put responsibility of the program working on you instead of people maintaining a package in repository.

Connected with previous one - you need to manage dependencies somehow. Bundling is considered improper for a reason - in such case you need to ensure that you have updated the library to version without a bug - for example you didn't include openssl 1.0.1f into your bundle. Practise shows that people do include outdated libraries with known security vulnerabilities.


问:
Storing a pointer to an argument passed by (non-const) reference
When designing an interface for passing objects which are meant to be stored for later use and which should not be 'null', I am always a bit uncertain if the argument should be passed by reference or as a pointer.

This is an example of what I mean:

```<code>class Foo
{
private:
    Bar* m_bar;

public:
    Foo() : m_bar(nullptr)
    {
    }

    void Register(Bar& bar)
    {
        m_bar = &bar;
        m_bar->Registered();
    }
    // -- OR --
    void Register(Bar* const bar)
    {
        if (bar == nullptr)
        {
            // Error!
        }

        m_bar = bar;
        m_bar->Registered();
    }

    // Some method makes use of the stored pointer later
    void DoSomething()
    {
        if (m_bar == nullptr)
        {
            // Error!
        }

        m_bar->DoOtherThing();
    }
};
</code>```

My thoughts on this are:

The passed in reference may go out of scope before DoSomething gets called, but that may happen with the pointed to object as well.

Using the pass-by-non-const-reference version gets rid of duplicating the check for null and tells the caller that it is not possible to register 'nothing'.

It would be better to pass a reference in the constructor of Foo as it is required by DoSomething, but sometimes it this is not an option.

It would be better to pass a reference to DoSomething directly, but again, this is not always possible.

So if I need that kind of separate setter/register method, would it be clearer to use a reference or a pointer?

PS I know there is are two very similar questions Storing a pass-by-reference parameter as a pointer - Bad practice? and Reference vs dereference pointers in arguments C++/C, but I think they both are concerned with slightly different problems. The former deals mostly with the (ab)use of const and the latter does not say anything about storing a pointer. There may be another question/answer out there, if so, please just mark this a duplicate then!

答:
The problem in my mind is that whether you use a reference or a pointer, your class has a view into data that is created separately, may be destroyed separately, and the class has no way of knowing that.

```<code>Foo f;
if (something) {
    Bar x;
    // stuff with x
    f.Register(x);
}

f.DoSomething(); // screwed!
</code>```

It's not a good sign for such innocent code to do something so bad. It depends on the details of your intent which you haven't gotten into, but I'd probably just use a shared pointer. An alternative would be to have Bar's destructor reach into Foo and make the pointer null, but now Bar needs a pointer to Foo and it's getting a little silly. If you feel shared pointer doesn't mean your needs as an alternative to both solutions you considered, can you explain why?

Edit: let me briefly add that if in a similar situation to the one i outlined above, you do not want to extend lifetime as a shared pointer does, but simply to check validity and act appropriately, you could use a weak pointer, but that's starting to seem like overkill.

Body:
The problem in my mind is that whether you use a reference or a pointer, your class has a view into data that is created separately, may be destroyed separately, and the class has no way of knowing that.

Foo f;
if (something) {
    Bar x;
    // stuff with x
    f.Register(x);
}

f.DoSomething(); // screwed!

It's not a good sign for such innocent code to do something so bad. It depends on the details of your intent which you haven't gotten into, but I'd probably just use a shared pointer. An alternative would be to have Bar's destructor reach into Foo and make the pointer null, but now Bar needs a pointer to Foo and it's getting a little silly. If you feel shared pointer doesn't mean your needs as an alternative to both solutions you considered, can you explain why?

Edit: let me briefly add that if in a similar situation to the one i outlined above, you do not want to extend lifetime as a shared pointer does, but simply to check validity and act appropriately, you could use a weak pointer, but that's starting to seem like overkill.


问:
Why don't developers make installation automatic on windows?
This is the inverse to "Why don't developers make installation wizards on linux?", which is interesting, but made me think "Automatic installation is the natural way. Why do they use wizards?".

So here is the inverse question:

I'm sure it's not about laziness, or anything like that, but I fail to understand why developers, of even mainly consumer facing apps, don't make a fully automatic sort of installation where you are not bothered at all. The same apps usually have automatic installation on Linux, so why not Windows and Mac OS?

Is there any technical reason for this trend, or is it just convention?

答:
Informed Consent

Users should be able to decide, first of all, whether they even want the program to be installed on their computer or not.  It may seem self-evident to you that people are obviously choosing to install a program, but the prime characteristic of a malicious program is that it can be installed without the computer user knowing about it.

Informed consent is made even more explicit through UAC.

License Agreement

Most modern software follows a "click-through" model for licensing; that is, the user agrees to the terms of the license during the installation process as a condition of installing the program.  That users seldom read these agreements doesn't mean they're not bound by them, especially if they have clicked the checkbox labeled "I agree to these terms."

Configuring Options

Many software packages have options that allow you to change the way the software is installed in certain ways.  The most trivial of these lets you decide whether or not you want an icon on the desktop, but in larger applications you can decide which features you want installed.

Installation Progress

While programs in the Windows ecosystem are getting better at being less intrusive during the installation process (e.g. registry-free installation), installation is still often a non-trivial operation.  Progress bars and other visual aids give an indication that something is actually happening.  The final page in the wizard tells you whether or not the installation succeeded.

Getting Started

Finally, the best software packages tell you what to do next.  What are the first steps, how to get started, how to get help.  Most software, when installed, leaves you with a startup icon, and that's it.  Never overestimate the level of expertise of your users; as incredible as it may seem to you, there are still folks that don't know how to find and start software programs they just installed.


答:
I've often asked myself, and others this question, and I'd like to address a point I often see brought up before I get to why Linux sees fewer installers:

Linux distributions provide package managers.

However, I wouldn't say that a Linux distribution's package manager is a replacement for an installer for, in part, the following reasons:

These package managers aren't standardized in operation

A package manager is a bit like providing your binary and letting the end-user choose the installer. They can choose the terminal, or they can choose a tool with a more advanced GUI, but it doesn't afford you the same level control of the process as with a "traditional" installation wizard.

An example of what I mean by control is documentation. You can't give your end-user instructions like "Click Next, and you should see ". You can give command-line instructions for a specific tool, but then you're not only relying on the fact the user has that tool, but also losing most of the benefits of an install wizard (after all, most wizards are providing a front-end for simple command line instructions and kicking off scripts).

This also ties into aesthetics. Now you're depending on your end-users distribution to provide an intuitive/appropriate interface. While you are fully aware of that fact, it's not unreasonable for a more casual user to complain if double clicking your file (installer in their view) opens up an ugly package manager, does nothing at all, or worst of all opens up a terminal window. (The experiences I've had with users and their aversion of the "dos prompt" / "black and white box" / "Thing that's going to delete all their files if they look at it funny" could probably fill a book)

Package formats aren't standardized across platforms.

There are tools to convert between systems like rpm and deb, but it's not reasonable to expect your end-user to convert your packages if you're using them in a situation where an installation wizard would be provided on another platform (i.e. clicks-and-done).
Providing up-to-date packages for an additional package format can be rather straight forward if you have a rudimentary build system, but you're still adding a new binary that needs to be supported.

That's also adding a new binary people have to choose from depending on their platform (it sounds minor, but I'm sure someone here can attest to having to explain x86 vs x64 before [yes, there are ways to deduce the right platform from the browser, but then you're getting into even more complicated, and harder to support, procedures])

Package managers are "nicer" to open-source software.

This isn't saying that you can't share closed-source software with a package management system, it can definitely be done. But once you try to share close-source software on Linux distributions you run into a wall as far as your options for getting your software into common repositories is concerned. Things like PPAs or the openSUSE Build Service are out, and even the Canonical Partners repositories aren't enabled by default.

That means, unless you provide your own repository, you can't many of the major features of package management systems, including automatic updates. In my opinion, this is the most important benefit across most platforms that use these systems (e.g. iOS, Android, and Windows Store).

And even if you provide a repository (another job of variable triviality), you still need to get users to set it up (which is another layer of support, another set of non-standard approaches, and another diversion from the original point of the installer)

Now, having said all that, I still haven't addressed the original problem, why installers are less common on Linux in spite of these factors (amongst others). The original question asks if it's technical, or based on convention, and it's based on both in part.

If you look at the above factors I've mentioned, they also make things more complex for a "wizard-like" installer. For example, would your wizard include multiple package formats to install? How do you handle look-and-feel across distributions? The list goes on, and one thing that that packages do afford you is that none of this will be your concern (for better or for worse) as long you provide the right packages. And depending on the nature of your project, you can start to take advantage of those more "specialized" resources, like submissions of apps to the Ubuntu Software Center. This would all relate to the technical.

But the aspect that I personally find to be the driving force is convention. (I hope I've buried this deep enough that the people who downvoted that other answer to oblivion have stopped reading..)

I feel that poster had a point, but might have stated it too bluntly, and not actually provided objective reasons for that point. If you examine the differences I stated for a package manager and an installer, I wouldn't be surprised if you found most of them to be nearly non-issues (maybe even bordering on pedantic). But (excuse what I hope is viewed as legitimate use of an ad hominem argument) we're also users on site for programmers. I see Linux distributions pushed as an excellent Windows alternative for casual users (amongst many other things obviously). Not providing a commonly defined clicks-and-done procedure that all of these users can use really isn't ideal imo.

But at the same time, I don't find that many things in Linux to be especially ideal for that group either. Sure some distros have GUI-based package managers, but that means these people have to start looking into how to use a separate tool, on that isn't strictly focused on your program's installation (compare this and this to this).

Naturally you can use the GUI to do a majority your average casual user needs to do, especially with certain distros (ironically the things those distros are doing aren't always embraced in the open source community [look at complaints about Ubuntu and it's "walled garden"]) But I don't think it's deniable that Linux conventions favor someone who's comfortable with a CLI, or at the very least not deathly afraid it's appearance means they did something horribly wrong.

I'm not saying that this is what they aim for, but it's really what I see those conventions do. And package management systems in Linux seem to be following that. After all, most of their "downsides" nearly non-existent if your end-user is more comfortable with the underlying concepts.

Installers on most other platforms aren't really affected by that, and are designed so, to quote a comment on the question, "99.99% of users [can] blindly click "Continue". The problem with package management is getting those users to a "Continue" button, letting them know what that "Continue" button is (I've seen users get tripped up by tools that said press enter with other text), and letting them know when they've hit that "coast on clicking the "Continue" button" stage.


问:
Moving code to production without breaking existing functionality?
How can one move development / test code into production, and not end up breaking the functionality in Production environment? I am working with a small sized company, so they don't have a budget for a Test environment.

My goal is to move code to production and not compromise the user experience.  Given that in a production environment, I can't really create dummy records to process, because the application involves 3rd party vendor interaction.

Any suggestions? For this particular example, let's say web, MS.Net, non-cloud.
But even if these is a general best practice on how to move code, I would be interested in learning that. Alot of C level people who are not techies, expect things to run smooth, so when stuff breaks, lotsa finger pointing starts.

答:
The only way to reduce the risk of breaking things in production is to test new releases before deployment. Fullstop. And if your budget for testers is small, try to create as many automatic tests as possible. Learn about unit tests, automatic integration test, TDD, and train your team with these techniques - these are things which can be established perfectly in a small team. And if you believe testing is still to expensive, compare this to the costs when your production stops for one day.

However, no test can bring the risk of breaking things completely to 0. So what you should always have is a good fall-back strategy - if it turns out the new release did break something unexpectedly, you should always have the possibility to switch back to the previous release of your software as soon as possible. This is mostly an organizational task, for example: make sure every release is archived somewhere, make sure the people who know how to install the software or the previous release are not going on vacation the day after deployment, make sure the database is backuped immediately before deployment, simplify the installation process, and so on.

Here is a former PSE question which deals with the question what to do when things break in production. Note that this post assumes there is a test environment.


问:
FizzBuzz - really?
When it comes to "interview test" questions, the subject of FizzBuzz often comes up. There is also a Coding Horror post about it.

Now, if you bother reading sites such as this, you are probably less likely to be in the demographic of programmers who would find FizzBuzz anything but trivial.

But is it really true that 99% of programmers will struggle with it?

Really?

What is the evidence to back this up?

Some real-life examples would be very helpful in answering this question.

答:
I am still a relatively junior programmer (I have been coding for money for ~2 years and coding in some professional capacity as a side-responsibility for about 2 before that) so use sufficient grains of salt.

I have some experience doing a first screen for coders for a Large Enterprise Project (we kinda knew the project was doomed, but hey, they wanted to pay anyways). As the only programmer at the firm doing the hiring I was given the task of reviewing resumes and screening applicants.

This was for a government project so it perhaps probably didn't attract the most talented applicants, but I did not receive one application from anyone with a github account that actually had code shown, nor anyone who had a portfolio, so I used fizzbuzz (literally the exact problem) as a first pass on anyone who looked like they might be able to program.

I prefaced it with a pseudo-apology stating that I knew it was stupid but that I just wanted to see any working code, and if they wanted they could send another example of equal or greater value or really anything, but that fizzbuzz would suffice.

The result: I didn't get one response that was actually correct, which is mind-blowing considering the volume of answers on the internet. No one even bothered to plagiarize. We had to just go with hiring people who had previously worked on the failed previous iterations of the project.

After the initial shock of the exercise and disappointment about how screwed government software/contracting was, I felt much better about my own skills, so small victories?

Edit: By not correct I don't mean an off-by-one error (i.e. I asked for through 100 not 99) or some other innocent bug that is an easy fix. I mean not functional, either won't run/compile/etc or showed clearly that the problem was just not read and understood, also a significant portion withdrew the application and not one sent some other code instead.

Title: FizzBuzz - really?


答:
Most closed-source, non free-as-in-beer software for Linux does come with installation wizards.  So does some closed-source, free-as-in-beer software, at least until most major distributions pick it up.  For open source software, package managers are a clearly superior solution.

So what about the early stages before open source software gets picked up by the major distributions?  Why don't developers create installation wizards during that phase?

First of all, a lot of open source developers plain don't care about distribution.  They write software for themselves to use, and put it out there in case it is useful to others, but they see packaging for distribution as someone else's problem.  If it's liked enough, someone will take upon themselves the task of getting it into their favorite distribution.

The open source developers who do care about distribution are still better off working within the package manager system, because that's where their customers are.  Linux users don't typically search the web looking for software.  They search their package manager first.  Failing that, they search the "community maintained" repositories, like Ubuntu's PPAs or Arch's AUR.  If you aren't in those places, your software most likely won't get noticed, and if it gets noticed, it's less likely to be trusted.

Foregoing those existing distribution channels is sort of like deciding superbowl ads are too expensive, so you're going to host your own football championship and advertise on there instead.  It may be less costly, but it's also less effective.

As far as customizing the configuration goes, for software like a web server that's traditionally easier to handle with a config file, which makes the configuration easier to share, back up, and restore.

For client software like a web browser, it's much better to create a configuration wizard that appears the first time a new user runs the software, rather than do it at installation time.  The main reason is Linux is a multi-user operating system, so you want to customize it per user anyway.  This also makes it easier to rerun the configuration wizard later, for whatever reason, without having to keep the installation program around to reinstall the entire software.  This type of wizard is fairly common in Linux software.


答:
they don't have a budget for a Test environment

If they have the budget for a live environment and a developer, they can find the budget for a test environment.  The cost of mistakes in the live environment is more expensive than paying for a test environment up front. A test environment can be a scaled down clone of a live environment.  In a virtual setup like AWS the test systems can be turned off when not in use, costing $0 most of the time.

Also work with the 3rd party vendors to use their test environments or at least set up test data in their live environment.

Title: Moving code to production without breaking existing functionality?

Body:
How can one move development / test code into production, and not end up breaking the functionality in Production environment? I am working with a small sized company, so they don't have a budget for a Test environment.

My goal is to move code to production and not compromise the user experience.  Given that in a production environment, I can't really create dummy records to process, because the application involves 3rd party vendor interaction.

Any suggestions? For this particular example, let's say web, MS.Net, non-cloud.
But even if these is a general best practice on how to move code, I would be interested in learning that. Alot of C level people who are not techies, expect things to run smooth, so when stuff breaks, lotsa finger pointing starts.


答:
Window use msi files, which largely work the same way as other program packages. They can be installed silently by setting a flag, but the default behaviour is that Windows present a GUI with all the configuration options defined in the package. To a normal user msi files therefore behave just like exe installers.

As a user who will often choose to change the defaults, I find that using the GUI is the easiest way to learn what options I have when installing a program, and it is convenient for changing them at the same time.

Concerning the possibility of an installer that is by default completely silent. On Windows it is customary that the user is allowed to choose the installation directory, you'd get on the wrong side of a lot of users if you didn't allow that option in a GUI. Also, users are used to see at least a minimum of dialogue when installing a program, if you show nothing they might think that the installation failed.

Title: Why don't developers make installation automatic on windows?

Body:
This is the inverse to "Why don't developers make installation wizards on linux?", which is interesting, but made me think "Automatic installation is the natural way. Why do they use wizards?".

So here is the inverse question:

I'm sure it's not about laziness, or anything like that, but I fail to understand why developers, of even mainly consumer facing apps, don't make a fully automatic sort of installation where you are not bothered at all. The same apps usually have automatic installation on Linux, so why not Windows and Mac OS?

Is there any technical reason for this trend, or is it just convention?


答:
From what I've seen, it really boils down to the whole "Windows experience". That is, making any action or option as visible to the user as possible.

The reason I say this is that a GUI is not necessary for installation. MSI-based installers can be silently installed in a similar fashion to Linux-based packages. The GUI is completely optional, but again is there to give the user a visual representation of what is going on in the background.

In Linux, this is easily accomplished by use of a package manager. If I want to install a package, I have to specifically request that package. For the less technically include, usually a GUI-based package manager is available for the user to install desired software.

In Windows, no such thing exists. If a user wants to install Windows-based software, they have to find and download the software separately. There is no standardized tool to assist the user in configuring and installing the software. Therefore the install GUI that comes bundled with each software is very much alike the package manager GUI in Linux. It simply exists to allow the user to configure the installation and track its progress.

There are plenty of cases where an install GUI is not necessary due to the presence of a management GUI. For example, the popular Steam platform will install any games or software available through the steam store automatically with the assistance of install scripts.

Another great example would be SCCM. System Center Configuration Manager (SCCM for short) is a software used to manage groups of computers on a network. It includes the ability to make software available for install through a GUI called Software Center. Any MSI-based installer can be made available to install at the click of a button. In the environment that I work in, we have software ranging from Adobe's Creative Suite to things such as WinZip available. All a user needs to do is search the catalog to find what's available, click install, and wait for confirmation. It is almost the exact same process as if I wanted to install something on my home computer running Linux Mint.


问:
How should I break this user story into tasks
I am trying to understand how to create user stories and tasks. I have read articles stating that you should create small user stories and they should be a "vertical slice" of functionality instead of a "horizontal slice".

I have a user story:

As a buyer I want to add items to the shopping cart so that I later can buy the items.

From my understanding tasks should be the things you have to do in order to complete this user story. Am I right if the tasks should also be created as "vertical slices" instead of "horizontal". Instead of creating a task for "create shopping cart model" I would have a task "Update shopping cart service to be able to add products".

But with that task I only have one task, is it to big, should it be broken down in another way? Is it bad that a user story only have one task?

答:
It Depends :)

I don't know the context of this story, but on face value it sounds to me like the only task here is add-item-to-cart. In a typical browsing/shopping application, this would be an AddToCart button, with appropriate button-click logic, where the user/cart identity already exist.

If user identity and a cart cannot be assumed, I suggest that you don't break them out as tasks under this story, but instead separate them out as new stories.

If you just reveal the presence and behavior of the cart (and/or user identity, if necessary) via a task breakdown, you will have missed an opportunity for much more informative, valuable conversations with the users (what does the cart look like? where should it appear? can you remove items from the cart? etc.).


问:
Is a web application only something that has a UI that runs in the browser?
Consider an application that relies heavily on the internet. It constantly talks to a remote server. However it's UI is a desktop program that doesn't live in a browser.

Would you consider such a thing - a 'desktop application' (or a native mobile one, etc.) that relies heavily on the internet - a web app?

Wikipedia says:

A web application or web app is any application software that runs in
  a web browser...

A lot of applications might do the majority of the heavy lifting in a remote server (and some lighter stuff on the client machine). But they don't run in a browser. Are those not 'web apps'?

答:
A desktop application is not a web application.

A native mobile application is not a web application.

The fact that a desktop/mobile applications relies heavily on internet resource doesn't change anything. Nowadays, most applications do, since they need to empower their users with centralized online storage, off-site backups, the power of cloud computing, etc.

Note that it doesn't matter where the web application performs most of processing. There is a distinction to make between a website (something which displays mostly static content and provides only basic interactivity) and a web application, but a web application may run entirely on client side (though JavaScript), store all the data on client side as well, and use a server only to retrieve source files (HTML, CSS and JavaScript).

Are web applications really different from desktop ones?

The distinction between a desktop/mobile application on one hand and a web application on the other hand matters for the following reasons:

Desktop and native mobile applications have usually more permissions than web applications. Web applications are run in sandbox and have no or low permissions on client side. They can eventually store their data (given that even this can easily be overridden by the user) on client machine, but cannot access hardware and person's files in the same way desktop applications do.

This applies as well to RIA (Flash and Silverlight), which have a limited set of privileges compared to a desktop application.

Desktop and native mobile applications can benefit more in terms of performance for being close to the hardware. This tend to be less true recently, especially given the advance in terms of performance of V8 JavaScript engine, but still true for anything computationally intensive or something which pushes the hardware to its limits. If you're not convinced, imagine Crysis 3 rewritten in JavaScript and fed trough a browser.

Desktop and native mobile applications can provide much more in terms of user experience (UX). Even with HTML 5 and CSS 3, web applications are very, very far from the capabilities, in terms of UX, of desktop applications. Shortcuts are a good example: if you're not convinced, try to respond to shortcuts such as Ctrl+Shift+N in your web application and don't forget to test how well it works in Chrome.

Some companies make a difference between web programmers and other programmers when hiring people. Web development requires slightly different knowledge compared to the one needed to develop applications for PCs or mobile devices.

On the other hand, the gap tends to shrink considerably with the efforts of companies such as Microsoft to bring a common set of tools and paradigms for both worlds. For instance, writing an application in WPF is not very different from writing one for Silverlight.

The way of distribution is different. Usually, a desktop application is downloaded and installed by the user, and the user has to make an additional effort in order to get a more recent version of the application. The effort can be as large as a new purchase (for example buying Microsoft Office 2013 to replace Microsoft Office 2007) or as small as a mouse click (for example installing a security update for Microsoft Office 2007). On the other hand, the user has usually no control over the updating and upgrading of a web application; those are often done silently.

Note that recently, more and more products tend to follow the model of web applications. Google Chrome is an excellent example: updates are done automatically (like Firefox) and in a non-intrusive way (unlike Firefox). Pay-per-month subscriptions also contribute to this movement for paid applications.


答:
It seems to me you want to protect your application from two perspectives:

You want to make sure that only authorized people can modify your role-based security via the official user interface for role-based security management.

You want to make sure that people can't view or modify your role-based security via an unofficial mechanism.

This first part is pretty easy, you include a role in your application for maintaining role group members and role authorized actions.  Connecting this to (or forcing it into) your customer's AD is a bit dubious.  You don't know how well the customer manages their AD.  Also, what if they use something other than AD?  The complexity of connecting to and integrating with your clients' AD is something that may raise its own HIPAA or security concerns, i.e. some clients may not allow your application to connect to your AD to get information about users.

The second part is a concern for storing your role information in a database.  How many people know the DBA password for your clients' systems?  You don't know, so how can you be sure that you are secure?  You want to encrypt the role information in your application's database and obfuscate the code that accesses it.  This will reduce the risk of someone viewing or changing the role rules with plain old database tools, for example.  Since you're dealing with private information, you probably need to consider encrypting all of your sensitive data, not just your role-based security rules.

Let your client's IT department concern themselves with who can get basic access to your application.  This is the bread and butter of IT departments.  Once a user gets to your application, however, you need to take responsibility for who is logged in and what they can see and do.

Title: How to securely implement roles in a Windows Form application?

Body:
As an ISV, what is considered best practice for implementing application role based security? In other words, only allow users to access certain features in the application based on what roles they belong to.

We currently just use a table in our database to store this, but it has been suggested that for maximum HIPAA compliance, this isn't secure enough.

My first thought was to just use Active Directory groups, as it would seem that is what they are designed for, however, it just doesn't seem practical to rely on our clients IT departments to create groups and assign users to them for groups that are specific only to our application. This can't be best practice for ISVs...

At this point it my research, it seems that possibly the best solution might be to use something like Active Directory Application Mode (ADAM) (Active Directory Lightweight Directory Services) and possibly AzMan (Windows Authorization Manager)?

Again, this is for a Windows Forms application, not a Web application or in an "in house" solution.

If it matters, we are also in the process of transitioning our home-baked authentication to instead use active directory for authentication.

Also of note is this needs to be secure (HIPAA compliant).

All the information I can find on these subjects seems to be for developing applications for in house use, or for web applications, and neither of these approaches feels appropriate for a Windows Forms application.

(We are using .NET for development.)


问:
What is the risk of putting your actual developing code online
My question came from this question

It seems to be actual developing code for a real application. What If your contract says that all code you made for app of your employer is a secret? Isn't it risky to copy code fragments like that online (if you read carefully, it gives information about the database)? Wouldn't it be better to write something like this?

```<code>DataTable1 = datatable with a lot of data;
DataTable2 = other datatable with a lot of data;

for (int i = 0; i < DataTable1.Rows.Count; i++)
{
    if (DataTable1 ["Field1"]).ToString() != SomeValue) // this statement doesn't work
    {
        DataRow dr = DataTable2.NewRow();
        dr["Field1"] = "";
        dr["Field2"] = "*" + DataTable2["Field1"];
        Datatable2.Rows.Add(dr);
    }
}
</code>```

答:
If you have signed an NDA which specifies that you should keep in secret all code you have written for your employer, then by copy-pasting fragments of that code on Stack Exchange, GitHub or anywhere else, you put yourself to the risk of having a lawsuit.

The contract may specify the consequences of violating the NDA.

The fact that the code contains nothing special which can be used by competitors (and given the low quality of the actual piece of code, I hardly doubt any competitor will copy it) and doesn't contain sensitive information such as passwords doesn't change anything.

You should have read your contract more carefully (especially before signing) and avoid posting code online.

Wouldn't it be better to write something like this?

How close is the piece of code to the original is usually considered by the judge.


答:
Thats part of the reason why an SSCCE (or in SO parlance, MCVE) is often suggested.  Writing such is less likely to be an issue with copyrights, more useful to the person answering the question in isolating the issue, and likely more useful to the next person who comes to find it.  Note that in many cases just doing this exercise of creating an SSCCE will help identify the bug without asking the question.

If your contract says that the code you write must not be disclosed, you should consider asking your employer about asking a question on Stack Overflow and possibly sending the question to the employer who can say "yep" or "nope" to the question before posting it to make sure that there are no issues with disclosing it as part of the question.

I will point out that for my own situation, neither Deserializing map key with Gson expects an object nor Apache POI autoSizeColumn resizes to minimum width contain any proprietary code from my employer at the time, though both were from problems that I had encountered while working on software for the employer.

Title: What is the risk of putting your actual developing code online

Body:
My question came from this question

It seems to be actual developing code for a real application. What If your contract says that all code you made for app of your employer is a secret? Isn't it risky to copy code fragments like that online (if you read carefully, it gives information about the database)? Wouldn't it be better to write something like this?

```<code>DataTable1 = datatable with a lot of data;
DataTable2 = other datatable with a lot of data;

for (int i = 0; i < DataTable1.Rows.Count; i++)
{
    if (DataTable1 ["Field1"]).ToString() != SomeValue) // this statement doesn't work
    {
        DataRow dr = DataTable2.NewRow();
        dr["Field1"] = "";
        dr["Field2"] = "*" + DataTable2["Field1"];
        Datatable2.Rows.Add(dr);
    }
}
</code>```


答:
The point of taking a story-based approach is to deliver customer value incrementally. Ideally, you'd use practices like pairing and TDD so that the code can evolve incrementally as well.

That means that stories should be as minimal as possible, and therefore I'd break the error handling out into a separate story. It's hard to write the details of the error-handling of a story until you've done the story, so it's easier to put that off.

As a better explanation of why, say that I have 5 stories that I need to do before I can get feedback from my customer. The more minimal I can make those stories, the quicker I can get them done and the quicker I'll get feedback. Whenever I get customer feedback, there's the chance that it will invalidate the work that I've already done, so I want to minimize the amount of work that it might invalidate. For your credit-card page, I would gladly demonstrate a page hooked up to a fake service to decrease my time-to-feedback.

The other advantage of more stories is that they are easier to fit into sprints. If the mainline is done and the error handling isn't, I can consider that "done" for the sprint, but if it's all together I'll have to split them apart, which is often problematic.

Finally, teams just feel better getting two small things done than one big one.


问:
When should a class be final?
I've only really seen this on Java's wrapper classes (String, Integer, etc.), but never in open-source projects, and I was never taught about it in any books or classes. I know it means the class can't be extended, but I don't know when that would be useful for any class outside the aforementioned JVM-low classes. So, when would I want to use the final modifier on a class, if ever?

答:
Whenever you don't want the class to be extended.  Designing for extension has a cost (see also Eric Lippert's Blog: Why Are So Many Of The Framework Classes Sealed?) - you need to make sure you provide the right hooks for the class, that people can implement those hooks without breaking things, that you can be reasonably sure that subclasses won't be nefarious (this is especially important with core language classes like String and Integer), that the contracts that the superclasses implement are clear (so that subclasses don't break them easily).

This takes work, time, and thought to put into it.  It isn't easy developing a class that is meant to be extended.  And sometimes, you know you don't want it to be extended - that it can be put to nefarious use and cause havoc with your implementation if someone passes you a mutable String rather than an immutable one.

And so, you make the classes final.  There can be no mutable String, because its an immutable class and its final.  You know when you get it, it won't be changed from under you in some way.  You can save it and be sure that that it will behave like a String, always - no subclasses can be made to make it be otherwise.

Thus, there is a bit of design that some follow that all classes start out as default to be final.  How often are you going to subclass that DTO? And when you do want to subclass it for some reason, you should spend some time thinking about the implications of removing the modifier.

There is a check style  rule Design For Extension.  Personally, I like it.  In every non-final class, every method must be one of:

abstract

final

empty implementation

This sort of thinking then allows you to write subclasses that are clearly implemented the proper way - providing hooks and preventing the superclass fro being broken by the subclass not knowing about tinkering the innards of it in an unexpected way.  Though, admittedly, this design philosophy means that the subclasses are more limited in their flexibility - but they can't corrupt the state of their superclass.

Again, if you're not prepared or willing to design a class so that it can be extended cleanly, it is best to design the class so it can't be extended at all.

Title: When should a class be final?

ContentLicense: CC BY-SA 4.0


问:
How to connect Android App to MongoDB deployed on Google Cloud
Currently I am working on a simple app which will be able to connect to MongoDB which is deployed in Google Cloud. I have set it up MongoDB ocaly on my computer and I have made a little JAVA console app which connects to local MongoDB an I am able to do certain tasks like creating new collections, databases, retrievieng collections, deleting databases and collections, everything is working locally.

Problem which I have is that I want to connect Android App to the MongoDB which is deployed on Google Cloud. I have read on the web that I need to use some REST API to this task such as Crest Node.js but in other resource their saying it is impossible to connect like that. I am a bit confused, can you please explain me what I need to do make a sucessfull connection to the MongoDB from Android?

Edit@
What I have found out that one on Google Cloud there is only database created, there is no any virtual instance of Linux based system deployed so do I have to create a new Linux instance, install mongoDB in this instance and also a REST API and then make a connection with the server?

答:
It is not a good practice to connect your Android application directly to your MongoDB database/cluster. The drivers are using TCP sockets to connect and deal with some pooling and many other things.

So as you mentioned the proper approach is to create a service layer, today REST API, that is running on your cloud infrastructure. You can deploy a Node or Java API that expose all your services to your mobile application.

In this case your Android application just call the REST API over HTTP.

You can look at this tutorial from Google that explain how to deploy a node application and mongodb database on GCE:
https://developers.google.com/cloud/mean/

You can extend that to Java.


问:
What is the best way to store multilingual data in MongoDB?
I want to save/serve multilingual data in my CMS application using Mongoose.

Is this the correct way?

```<code>name: {
    global: {
        type: String,
        default: '',
        trim: true,
        required: 'Please fill name',
    },
    en_US: String,
    tr_TR: String,
    sv_SE: String
}
</code>```

答:
I do not this that you have any "correct" or "bad" way, it is mostly based on your application design and requirements.

However, you may have noticed that in MongoDB 2.6.x the Full Text Search feature supports multi languages indexing and search if you specify a language in a document. This allow you to search text by language.

Documents look like:

```<code>{
_id: 1,
   language: "portuguese",
   original: "A sorte protege os audazes.",
   translation:
     [
        {
           language: "english",
           quote: "Fortune favors the bold."
        },
        {
           language: "spanish",
           quote: "La suerte protege a los audaces."
        }
    ]
}
</code>```

for more informations:

http://docs.mongodb.org/manual/reference/text-search-languages/#text-search-languages

Body:
I do not this that you have any "correct" or "bad" way, it is mostly based on your application design and requirements.

However, you may have noticed that in MongoDB 2.6.x the Full Text Search feature supports multi languages indexing and search if you specify a language in a document. This allow you to search text by language.

Documents look like:

{
_id: 1,
   language: "portuguese",
   original: "A sorte protege os audazes.",
   translation:
     [
        {
           language: "english",
           quote: "Fortune favors the bold."
        },
        {
           language: "spanish",
           quote: "La suerte protege a los audaces."
        }
    ]
}

for more informations:

http://docs.mongodb.org/manual/reference/text-search-languages/#text-search-languages


答:
Besides of being bound to an NDA or not: It is in every case bad practice to leak any information of your company's code to the internet. The stuff proprietary to your company really doesn't matter in most of the cases: it contains no valuable information to solve your problem. So leave it out.

Everytime, when I am asking something on SO, I write as much pseudo-code as possible or try to scramble as much as possible.


问:
How to advocate Stack Overflow at work
I am thinking of doing a short presentation at work about using Stack Overflow as a resource for your day job.

What is your experience doing this?

Would you deem it a valid resource to tell your colleagues about it or is it similar to telling them about Google as a resource?

Is there a better way of doing it?

I was leaning toward asking questions side of Stack Overflow rather than answering them to avoid you-shouldn't-be-doing-this-on-work-time argument.

Just as a follow up.

Originally I didn't want to make the question too specific to my own case. My presentation will only be a quick four minute talk, which I will repeat over an hour to different groups.

I may ask a question before the talk on Stack Overflow and refer to it during the presentation. Hopefully I will get some activity during the hour.

I am also going to talk briefly about some of the other Stack Exchange sites that would fit the audience as they are not all developers. I think Super User, Server Fault and Programmers should work well.

I will not be doing the presentation for another couple of months as it has been rescheduled, but I will update on how I got on.

答:
I wanted to comment, but it became too big for it.

I always prefered to refer or recommend Stackoverflow and other stackexchange sites privately, next to a cup of coffee or something like this.

If I speak to a junior I always tell them to check it out, if they didn't already, it is useful. There are collegues who use some hungarian site with forum capabilities, I guess because of lack of general English knowlegdes. Sometimes I recommend other stackexchange parts like programmers or server fault, super user too when it comes to debate about "best practice" or hardware, server operations etc... I was surpised when I learned many of programmers know only about Stackoverflow, and not other stackexchange sites.

I would say it might have a good point to introduce Stackoverflow and for example programmers.stackexchange in a presentation, but I wouldn't do it for a hundred people. Maybe just to my group's or project's people.

Title: How to advocate Stack Overflow at work


答:
Disclaimer: This is largely speculation, however is based on my experiences packaging Windows applications for installation & deployment.

Its all down to what the de-facto standard for installation is on a platform. On linux the standard is to use package management tools such as apt (dpkg/Debian based) or yum (rpm/RedHat based) for installation. Once you have provided a package for deployment building a wizard is pretty much a waste of time as the vast majority of users will just use the package anyway (as its the standard).

Converely on Windows the standard is a GUI based installation. There are alternatives, however none of these alternatives are suitable as 100% replacements for an installer:

There are package management tools (such as Chocolatey, however none of them have reached critical mass yet - if you only provide package management based installation then many users are going to be annoyed that they need to install some other piece of software just to install your program (think of how annoying download managers are). Most package management tools are also targeted firmly at technical users, and so if your software isn't intended for that  userbase then providing a package for Chocolatey is going to be a complete waste of time as nobody will use it.

Some software is suitable for XCopy deployment, however this only works for relatively simple software products. Its good for users who want to install to a flash drive (for example), however for everyone else its faff. As a result many projects that choose to release files for XCopy installation also provide an installer.

Chocolatey provides a command line snippet which downloads and runs the installation. Again, while its quick and works well for technical users, non-technical users will struggle and be put off by this installation method.

If your software is complex enough to require deployment its pretty much mandatory to provide a GUI installation as its what users expect. There are also a number of products which make building these wizards fairly easy, so a providing a GUI based installer is generally one of the lowest-effort options in terms of development time. Once you have a GUI based installer you need to evaluate the cost-benefit ratio for each of the above (remember that new featues start with minus 100 points), and for many products its simply not worth the effort to build and maintain these alternatives.

Note that installers with some sort of "silent" mode are pretty common on Windows, however this tends not to be the default mode - again as its not the standard. Most Windows users would find an installer that immediately installs itself as soon as you run it fairly disconcerting.


答:
The world wide web is a system of interlinked hypertext documents you access via the internet.

A web-application is an application that uses this structure.

Any application that doesn't use this structure but does rely heavily on the internet, is not a web-application it's an internet application.

The world wide web and the internet are not the same. The web runs on top of the internet but so do a lot of other things.

Title: Is a web application only something that has a UI that runs in the browser?

Body:
Consider an application that relies heavily on the internet. It constantly talks to a remote server. However it's UI is a desktop program that doesn't live in a browser.

Would you consider such a thing - a 'desktop application' (or a native mobile one, etc.) that relies heavily on the internet - a web app?

Wikipedia says:

A web application or web app is any application software that runs in
  a web browser...

A lot of applications might do the majority of the heavy lifting in a remote server (and some lighter stuff on the client machine). But they don't run in a browser. Are those not 'web apps'?


问:
Is there a technical reason why you can't develop iOS apps on a Linux computer?
I understand why you can't develop OS X apps on a Linux computer, but is there a good technical reason why you can't develop iPhone and iPad apps on Linux?  Why isn't it possible to compile iOS source code into an iOS executable and run it in an iOS simulator on Linux or install it on a development iOS device?

Is it just because the XCode IDE is a Cocoa application?

You can develop Android apps on any kind of platform, it seems. I don't see why the same can't be true of iOS.

答:
I think it should said you can develop for iOS on other platforms, you just can't build final applications on them.

It's been explained in the accepted answer why you can't build outside of OS X, but there are many development tools that allow you to write iOS apps on other platforms.

Some of the development tools that I've used that allow this  :

Qt Framework (C++ and Qml): Applications can be written in Windows or Linux then the iOS application is built with XCode on OS X.

Unity3D (C#, UnityScript, and Boo): You can develop on Windows and to build an iOS on either platform you generate an XCode project. This also allows further integration with other Objective-C code.

Xamarin (C#):  You can develop on Windows (and I believe Linux), and use an OS X machine as a build host.

Kivy (Python): Also Generates XCode Projects.

And you can find many more projects like these, especially once you start looking at hybrid and mobile web app frameworks like Appcelerator.


答:
Developers do make installation automatic on Windows, but not all software is offered in this format. Contrary to many other answers here, Windows does have a standard and widely used "package manager" (bear with me), but it is relatively little known even among developers because it targets enterprises, not end users.

It's called SCCM and is used by every large enterprise to manage their Windows installations. In addition to being able to manage packages (push software and dependencies to client machines), it also manages updates to Windows and other installed software.

SCCM is not used even by technical users for managing their own computers. It isn't really meant to offer much of a benefit for managing a single computer; in fact it may not even work without Active Directory / non-domain-joined machines. So I wouldn't really call it a Windows package manager, even if it does manage software & update deployment.

However, my point here is that there are automatic installations on Windows, and they are widely used – by system administrators in large enterprises. If you see a product offering an .msi download, it's probably because it wants to be automatically deployable to thousands of machines via SCCM.

Disclaimer: I myself have not used SCCM, and know little about it, so I could be wrong about some subtleties above.


问:
Who is a tester?
I don't really understand the concept of testers. I just graduated and before I joined into workplace I thought I'd be pair programming with testers and using TDD where they will be writing tests and I will be passing them or something similar. However that's not the case. Apparently none of them that I have seen knows how to code. A few of them knows using basics of scripting languages, but that's pretty much all.

So essentially what happens is, when I am done with my code, I write tests (unit, integration etc.) for that and then push my code in. I tell tester what it is and what it does, then the tester tests the functionality and approves or asks for further discussion. I really don't see any use of this. I wish I could just tell them what I coded and they would just write the tests.

I also have seen some brilliant software developers being testers at tech companies (Google, Microsoft etc.). Why do these developers want to become testers? Are their developer skills actually being used? If so, by how?

I am so sorry, I am really confused about this whole tester concept (and yes, it's not taught at university). I also have read the question Are programmers bad testers? however it mentions programmers getting involved of manual testing. While I have no doubt that a tester is great at testing a project, I found it a bit unnecessary for them to test a little functionality (ie this button submits a post request to xyz end point and sends these values).

答:
The term 'tester' gets applied to a whole range of professions that all do slightly different work. What testers have in common is that they

try to break that beautiful piece of code you have just written

look for edge cases and unexpected interactions between requirements

provide their own, independent and uninfluenced, interpretation of the requirements

look out for unexpected and/or uncomfortable reactions of the system

Some kinds of testers are:

Test automation engineers are the 'programmers' under the testers. They generally write scripts in various languages to perform automated tests on a system. Usually, the system as a whole is tested as a black box, but sometimes the test scripts are more on an integration or unit-test level with a white-box system.

Test engineers write 'test scripts' that are meant to be executed by hand, either by themselves or by the manual testers. These scripts should be based upon the requirements and/or issues that were previously reported.

Manual testers are the ones that mainly execute (manual) test scripts and play around with the system as a kind of power user.

Traditionally, testers are not expected to have programming knowledge, and any testing that requires it (such as unit- or integration testing) falls under the scope of the programmers and the testers only come into view when you don't need programming tools to interact with the system under test.

With test automation, the testers might come deeper into the code, but it is unlikely that they will ever start to work side-by-side with a programmer on a piece of code, because that would compromise their independent view on the requirements too much. This independent view is important, because it will bring unfounded assumptions and unclear or ambiguous requirements to light earlier.

Title: Who is a tester?


答:
I really don't see any use of this. I wish I could just tell them what I coded and they would just write the tests.

Well, that's not the world you live in. Besides, not everything can be done in automated tests. Additionally, "manual testers" are often people who have a lot better domain knowledge than the developers. Listen to them and you may learn a few things about why your system has the requirements you're implementing.

I also have seen some brilliant software developers being testers at tech companies (Google, Microsoft etc.). Why do these developers want to become testers? Are their developer skills actually being used? If so, by how?

They typically have the job title "Software Engineer in Testing" or similar. And yes, their developer skills are used in writing tests just as much as yours are used in writing applications. Setting up a test infrastructure for a large scale system can in itself result in a complex test system.

Title: Who is a tester?

Body:
I don't really understand the concept of testers. I just graduated and before I joined into workplace I thought I'd be pair programming with testers and using TDD where they will be writing tests and I will be passing them or something similar. However that's not the case. Apparently none of them that I have seen knows how to code. A few of them knows using basics of scripting languages, but that's pretty much all.

So essentially what happens is, when I am done with my code, I write tests (unit, integration etc.) for that and then push my code in. I tell tester what it is and what it does, then the tester tests the functionality and approves or asks for further discussion. I really don't see any use of this. I wish I could just tell them what I coded and they would just write the tests.

I also have seen some brilliant software developers being testers at tech companies (Google, Microsoft etc.). Why do these developers want to become testers? Are their developer skills actually being used? If so, by how?

I am so sorry, I am really confused about this whole tester concept (and yes, it's not taught at university). I also have read the question Are programmers bad testers? however it mentions programmers getting involved of manual testing. While I have no doubt that a tester is great at testing a project, I found it a bit unnecessary for them to test a little functionality (ie this button submits a post request to xyz end point and sends these values).


问:
How to deploy software automatically over SSH?
I am dealing with a distributed application which is going to mange a network of Linux-based servers spread among different places. Having the SSH credentials (as the most supported connection mechanism on these servers) we need to deploy our application seamlessly on these servers and run it there to become an new node on our network. Moreover we don't have and don't want super user rights. This is basically a requirement in a scientific environment to run simulations on a network of resources.

Is there any well known approach to such a problem?

答: Fabric can be used to run basic deployment commands (and configuration management tools such as Puppet or Chef) for a very nice SSH-based deployment process.</p>


答:
If you don't need additional layer such as Fabric:

Copy files to the server using scp, including the script to run,

Run the script through ssh.

In both cases, make sure you don't store SSH password anywhere, but use a pair of private/public keys.

Title: How to deploy software automatically over SSH?

Body:
I am dealing with a distributed application which is going to mange a network of Linux-based servers spread among different places. Having the SSH credentials (as the most supported connection mechanism on these servers) we need to deploy our application seamlessly on these servers and run it there to become an new node on our network. Moreover we don't have and don't want super user rights. This is basically a requirement in a scientific environment to run simulations on a network of resources.

Is there any well known approach to such a problem?


答: There is no technical reason at all that you wouldn't be able to develop ios applications on linux. In fact it already happens on windows in Delphi XE. There you can develop your ios apps totally in windows. The only thing in the end needed is that your apps need to be signed. This can only be done on a mac.</p>

Title: Is there a technical reason why you can't develop iOS apps on a Linux computer?

Body:
I understand why you can't develop OS X apps on a Linux computer, but is there a good technical reason why you can't develop iPhone and iPad apps on Linux?  Why isn't it possible to compile iOS source code into an iOS executable and run it in an iOS simulator on Linux or install it on a development iOS device?

Is it just because the XCode IDE is a Cocoa application?

You can develop Android apps on any kind of platform, it seems. I don't see why the same can't be true of iOS.


问:
Dealing with co-workers in a stressful work environment
Our department has been hit by some layoffs over the past year and we're running a skeleton crew.  They got rid of most of our support staff.  The remaining team members would rather worry about what others are doing rather than work as a team and figure out how to improve their own situations.

The one co-worker (who does network administration) spends long hours in the office.  Part of it is due to the workload but another part of it is due to bad time management (his own fault and management).  He'll walk past my desk and make snide remarks like "working hard?" and "do something".  If I offer to help, he acts like he doesn't need it.  He's kind of the insecure type and likes to do everything himself and then hold it over everyone else.  I'm afraid he might end up burning out.

Another guy has been bitching about his workload.  He spends as much time worrying about what others are doing than getting stuff done himself.  He thinks he's too good for "grunt work" and wants to be a manager.  When his plate is full, he makes sure everyone else knows it when he has to do get stuff done.

They're not bad guys but the stress seems to be getting to everyone.  I'm the only one left who knows how to code so a lot of time is spent on programming projects but also have support duties.  I can't get a whole lot done due to the interruptions.  The guys in the office don't consider what I'm doing to be "work"....and seem to think that I should be helping them with support and not programming.  So basically they think I'm supposed to work on IT support and then go back to the office to work on programming projects while they surf the internet.  I don't whine and moan and complain like everyone else does so they assume that I don't have enough to do.  So now I get to listen to snide remarks about my workload.  Management likes my projects because they save the company money.

What is the best way to deal with this situation?

答:
My experience is that the perception that you're not getting anything done is just as (if not more) lethal to your job as not actually getting things done.  It sounds to me like these people kept their jobs by creating that perception about other people thereby distracting attention from themselves.  Don't let them do the same to you.

Don't forget to sell yourself.  Make sure everyone knows about the work you're getting done.  Be less modest than you normally are.  And be assertive.  If someone walks by your desk with a snide comment like "Working hard?", tell them to mind their own business.

And lastly, start sending out resumes.  If things are this bad, there's a good chance your company will go out of business in the near future.

OwnerDisplayName: Lance