问:
Subclass only have methods without variables
Is it ok to have subclass which does not declare its own variables (instance variables) and inherits from super class or base class? It has methods and there are some common methods which it overides but do not have variables of its own.

Is it ok to have subclasses which defines behavior only or I am missing something? I want to divide in subclasses to separate logic of my classes. I have Medication class and I  want to subclass to DailyMedication , WeeklyMedication but I have all my instance variable in Medication as I do not have any specific for these classes. I want to make subclasses to divide logic as I have too much if conditions in my code.

```<code>MedicationEntity
name
dose
weekdays    //in case of daily and monthly this is null
monthdays   //in case of weekly and daily this is null
frequencyType  //Daily or weekly or monthly
etc
</code>```

EDIT: I want to make subclasses because these all classes have diffrent logic.I have enum of frequency(for Daily,Weekly etc) in my Medication class and this makes worse as i have to put all the checks in my code for these frequency type as if frequency is that than do that and if daily than do that as now i want to remove these switch conditions.

1)Also please suggest any good idea as weekdays is null if frequency is daily or monthly.But i need to send null to server.So where i can put weekdays if i subclass as it is not null only in case of weekly frequency but as i have to send null to server in request for all other frequencies.Should i put weekdays in subclass if yes than how i send null to server if frequency is daily as DailyMedication have no information about weekdays.

答:
Having three separate classes might make sense if you know you're going to add some special members to some of these subclasses and you just haven't gotten around to it yet (but you're going to really soon, right?).

Normally, I'd agree with the senior developer: This seems like an unecessary complication. Could you create an enumeration called Frequency and use that to determine which type of Medication you're dealing with, something like this pseudo-code:

```<code>Enum MedicationFrequency{MONTHLY, DAILY, WEEKLY, HOURLY}

class Medication
{
    private MedicationFrequency frequency;
    ...
}
</code>```

I suppose if you really want to keep the different implementations completely separate, you could try to inject specific algorithms into the Medication instances. Maybe something like this:

```<code>Interface MedicationProcess
{
   public void doSomething();
   public String getWhen();
   public MedicationFrequency getFreq();
}

class WeeklyMedProcess implements MedicationProcess
{
   String weekdays;
   public MedicationFrequency getFreqy() { return MedicationFrequency.WEEKLY;}
   public String getWhen() { return weekdays; }
   //...
}

class DailyMedProcess implements MedicationProcess
{
   public MedicationFrequency getFreqy() { return MedicationFrequency.DAILY;}
   //...
}

class MonthlyMedProcessimplements MedicationProcess
{
   String monthdays;
   public MedicationFrequency getFreqy() { return MedicationFrequency.MONTHLY;}
   public String getWhen() { return monthdays; }
   //...
}

class Medication
{
    private MedicationProcess someProcess;
    private String updateColumnName;

    public void setUpdateColumnName(String s)
    {
        this.updateColumnName= s;
    }

    public void setProcess(MedicationProcess p)
    {
        this.someProcess = p;
    }

    public doMedicationThing()
    {
        this.someProcess.doSomething();
    }
}
</code>```

Doing this in Java, You'd have a Spring configuration that might look like this:

```<code><bean id="dailyMedProc" class="DailyMedProcess/>
<bean id="weeklyMedProc" class="WeeklyMedProcess/>

<bean id="medication1" class="Medication">
    <property name="process" ref="dailyMedProc/>
    <property name="updateColumnName" value="weekdays"/>
</bean>

<bean id="medication" class="Medication">
    <property name="process" ref="weeklyMedProc/>
    <property name="updateColumnName" value="monthdays"/>
</bean>
</code>```

To answer your quesion about weekdays and monthdays, there are many ways to do this and it's not very clear from your question just what weekdays and monthdays are. Since you show them to be single variables, I'll assume they are just comma-separate strings.

It sounds like you also have columns in some table named weekdays and monthdays which need to be set to null if there is no value. Since you already know the frequency of the Medication (via its someProcess.getFreq), you know which field to set to null. The implementors of MedicationProcess can be required to implement getWhen, which will return the comma-separated list of days/month-days. With these two pieces of information, you can easily update the correct columns.

Having Medication have knowledge over what to do when specific MedicationFrequencies are encountered does break the design pattern a little bit. It's not great, but it's a simple solution.

If you don't like that, you could include the column name that should be updated for a specific instance of Medication. Only slightly better - I don't like mixing that sort of low-level data access into such classes, but I haven't seen the rest of your design, so maybe it's OK here...

Another option would be to have the MedicationProcess do its own database insert/update. This is a little trickier and I can't really give any concrete examples of how to do this without knowing the details about your schema, though I think this would be the best solution, if you can implement it.

There are other ways to implement the strategy pattern, depending on the tools and frameworks available to you.

Also, see: https://stackoverflow.com/questions/17721623/advantages-of-using-strategy-pattern-in-php The question is PHP-specific, but the answer is not.

Body:
Having three separate classes might make sense if you know you're going to add some special members to some of these subclasses and you just haven't gotten around to it yet (but you're going to really soon, right?).

Normally, I'd agree with the senior developer: This seems like an unecessary complication. Could you create an enumeration called Frequency and use that to determine which type of Medication you're dealing with, something like this pseudo-code:

Enum MedicationFrequency{MONTHLY, DAILY, WEEKLY, HOURLY}

class Medication
{
    private MedicationFrequency frequency;
    ...
}

I suppose if you really want to keep the different implementations completely separate, you could try to inject specific algorithms into the Medication instances. Maybe something like this:

Interface MedicationProcess
{
   public void doSomething();
   public String getWhen();
   public MedicationFrequency getFreq();
}

class WeeklyMedProcess implements MedicationProcess
{
   String weekdays;
   public MedicationFrequency getFreqy() { return MedicationFrequency.WEEKLY;}
   public String getWhen() { return weekdays; }
   //...
}

class DailyMedProcess implements MedicationProcess
{
   public MedicationFrequency getFreqy() { return MedicationFrequency.DAILY;}
   //...
}

class MonthlyMedProcessimplements MedicationProcess
{
   String monthdays;
   public MedicationFrequency getFreqy() { return MedicationFrequency.MONTHLY;}
   public String getWhen() { return monthdays; }
   //...
}

class Medication
{
    private MedicationProcess someProcess;
    private String updateColumnName;

    public void setUpdateColumnName(String s)
    {
        this.updateColumnName= s;
    }

    public void setProcess(MedicationProcess p)
    {
        this.someProcess = p;
    }

    public doMedicationThing()
    {
        this.someProcess.doSomething();
    }
}

Doing this in Java, You'd have a Spring configuration that might look like this:

<bean id="dailyMedProc" class="DailyMedProcess/>
<bean id="weeklyMedProc" class="WeeklyMedProcess/>

<bean id="medication1" class="Medication">
    <property name="process" ref="dailyMedProc/>
    <property name="updateColumnName" value="weekdays"/>
</bean>

<bean id="medication" class="Medication">
    <property name="process" ref="weeklyMedProc/>
    <property name="updateColumnName" value="monthdays"/>
</bean>

To answer your quesion about weekdays and monthdays, there are many ways to do this and it's not very clear from your question just what weekdays and monthdays are. Since you show them to be single variables, I'll assume they are just comma-separate strings.

It sounds like you also have columns in some table named weekdays and monthdays which need to be set to null if there is no value. Since you already know the frequency of the Medication (via its someProcess.getFreq), you know which field to set to null. The implementors of MedicationProcess can be required to implement getWhen, which will return the comma-separated list of days/month-days. With these two pieces of information, you can easily update the correct columns.

Having Medication have knowledge over what to do when specific MedicationFrequencies are encountered does break the design pattern a little bit. It's not great, but it's a simple solution.

If you don't like that, you could include the column name that should be updated for a specific instance of Medication. Only slightly better - I don't like mixing that sort of low-level data access into such classes, but I haven't seen the rest of your design, so maybe it's OK here...

Another option would be to have the MedicationProcess do its own database insert/update. This is a little trickier and I can't really give any concrete examples of how to do this without knowing the details about your schema, though I think this would be the best solution, if you can implement it.

There are other ways to implement the strategy pattern, depending on the tools and frameworks available to you.

Also, see: https://stackoverflow.com/questions/17721623/advantages-of-using-strategy-pattern-in-php The question is PHP-specific, but the answer is not.


答:
I can see this both ways:

make the sub classes:
If the sub classes have truly different logic, then by all means that logic should be separated even if there are no instance variables.  Think of the classic OOP "hello world" - a drawing program with Shape, and different subclasses for Square and Triangle.  CalculateArea() would be different, but they'd both work on height and width.

keep them together: In your example, I might have one class Medication with a property that represents the idea of an Interval or Duration.  In an ideal world you would have just one set of logic that would operate on an "Interval" without caring very much if it was every 1 hour, every 24, or every 168.

Without more information my suspicion is that your senior dev is correct for your particular situation.  (That's how senior devs get to be senior devs - by being right more often than they're wrong).

I think you're right to want to remove all that conditional code.  The question is whether it's better to hide the conditions in subclasses or to re-think the process so the interval becomes just a simple parameter.

Look at this another way: what would you have to do if your boss asked you to support a new time period (Daily, Weekly, Monthly, Every17Hours, Every3.5Days, etc.)?  Can you code your methods so instead of looking at enums you can just work off the interval?

It may be necessary to talk to the senior dev & see what he has in mind.  It's possible his concern is based on an insufficient grasp of the issues.

ContentLicense: CC BY-SA 3.0

Title: Subclass only have methods without variables

Body:
Is it ok to have subclass which does not declare its own variables (instance variables) and inherits from super class or base class? It has methods and there are some common methods which it overides but do not have variables of its own.

Is it ok to have subclasses which defines behavior only or I am missing something? I want to divide in subclasses to separate logic of my classes. I have Medication class and I  want to subclass to DailyMedication , WeeklyMedication but I have all my instance variable in Medication as I do not have any specific for these classes. I want to make subclasses to divide logic as I have too much if conditions in my code.

```<code>MedicationEntity
name
dose
weekdays    //in case of daily and monthly this is null
monthdays   //in case of weekly and daily this is null
frequencyType  //Daily or weekly or monthly
etc
</code>```

EDIT: I want to make subclasses because these all classes have diffrent logic.I have enum of frequency(for Daily,Weekly etc) in my Medication class and this makes worse as i have to put all the checks in my code for these frequency type as if frequency is that than do that and if daily than do that as now i want to remove these switch conditions.

1)Also please suggest any good idea as weekdays is null if frequency is daily or monthly.But i need to send null to server.So where i can put weekdays if i subclass as it is not null only in case of weekly frequency but as i have to send null to server in request for all other frequencies.Should i put weekdays in subclass if yes than how i send null to server if frequency is daily as DailyMedication have no information about weekdays.


问:
What is a good strategy for decoupling a web service that uses ACORD XML messages?
I work for an insurance company and we're getting ready to use a new vendor tool for creating insurance illustrations. The tool has a web service that accepts an ACORD XML message. We want to put a web service in front of the vendor web service to abstract it away, but the complexity of the data model makes it hard.

Our first method on the custom web service will probably just pass through an ACORD XML message to the vendor service and return the result. But, I'd like to have methods on our service that are more succinct. I'm not sure if that is possible yet as we're still doing analysis. Is there a way to create simpler data models for ACORD? The ACORD message is a TXLife 111.

Edit: We are a mixed shop with .NET and Java, so I need to consider that Java clients might, at some point, be requesting illustrations through our .NET web service.

答:
I also work for an insurance company (P&C, not Life).  I'm quite familiar with the nastiness that is ACORD XML.  Talk about something designed by committee, huh?  It's simultaneously verbose (lots of nodes) and vague (limited guidance on which nodes to use for what)... hard to believe.

My suggestion would be to build something like a facade pattern out of the web services in question.  In other words, you have this vendor service that expects ACORD XML for a request payload.  Your clients don't need to become ACORD experts -- they probably have a small amount of data that they collect.  So, build a facade that accepts something that's easier to provide (maybe a JSON REST endpoint), transform the JSON data into ACORD XML (into the proper parts of the node tree), and then run a process that "enriches" the bare ACORD XML so that it's acceptable to your vendor.  Then do the same thing in reverse on the way back.

You'll want your "enrichment" component to be as "rule based" as you can make it.  So for example, it'll know all the parts of the ACORD node tree that are mandatory, and will have default implementations for all of them.  It should also add nodes into the ACORD message that spell out precisely what it changed/added and why (you'll probably want to come up with an interface or abstract class that every rule implements).  Then, when you hand the response back to your client, you can tell them all the decorations you did to their request, which will become important because they're providing you maybe 10 pieces of data, you're enriching it to 100, and they're going to want to know where the other 90 things came from and why.

You may also want to build some kind of affinity between the REST endpoint payload and the enrichment component.  What I mean is that you may want to put something in the endpoint so that there's a defined way to "override" what your enrichment component does -- accessible  clear back to the rest endpoint request.  That way, if your consumer decides one of your rules is dumb, or not applicable, they have some way to get around it without you doing all the coding.  It might be something like a defined way to spell out an ACORD XPath and a value that you add into the node tree after your rules have run, and a defined way to delete an ACORD node list.

Finally, make sure you do good logging in your enrichment component.  Make sure you have a way to easily reconstruct what happened from the point where you receive the JSON request to the point where you hand back a JSON response to your consumer.  That kind of transaction-level logging becomes critical in this type of app.

Hope that's helpful.  I've done things like this for 15 years.  This general approach will save you a lot of headache.


问:
Property or Method to obtain information about a collection?
Suppose I have a MyList class which extends ObservableCollection<MyObject> where MyObject has the Boolean Property Enabled.

Let's say I want the number of MyObject objects that have the Property Enabled equal to true.

Should define this as a Property or a Method?

In MyList class, should I use:

```<code>public int GetNumEnabledMyObjects(){
    return this.Count(o => o.Enabled == true);
}
</code>```

or

```<code>public int NumEnabledMyObjects {
    get {
        return this.Count(o => o.Enabled == true);
    }
}
</code>```

I looked at Properties vs. Methods in MSDN Design Guidelines and I'm leaning towards a method since it might be considered expensive enough.

答:
My vote is to make it a method.  Count() is O(n), and I think you'd be hard pressed to find a property anywhere in Linq for a number of reasons, including Big O.

In any case, most clients expect Properties to involve looking up some state, and/or involve minimal processing (e.g. output formatting).  Retrieving a stored Count would qualify; iterating over a collection does not.


答:
Properties should be used as a shortcut to define getters/setters. Since what you want cannot fit into concept of being a field with only getter, you should define it as a method so that another developer using your class knows that it will cost to call the method.

Another option is defining a real field called NumEnabled and then managing this field as you add/remove objects from the collection. Then you would define it as a property because it is a field now.

If you want to reflect any changes on an instance of MyObject class' Enabled field, then you should define an event that is raised when the object's Enabled value is changed. The collection should subscribe to this event, so that the collection can track when Enabled value is changed for every object in the collection. You can then manipulate the NumEnabled property to reflect any changes made to any object's Enabled field in the list.

```<code>class MyCollection<T>
{
    Int32 NumEnabled{get;private set;}

    ...

    void Add(T obj)
    {
        ... // Add the object here
        if(obj.Enabled)
        {
            this.NumEnabled++;
        }
    }

    void Remove(T obj)
    {
       ... // Remove the obj here
       if(obj.Enabled)
       {
           this.NumEnabled--;
       }
    }
}
</code>```

Title: Property or Method to obtain information about a collection?

Body:
Suppose I have a MyList class which extends ObservableCollection<MyObject> where MyObject has the Boolean Property Enabled.

Let's say I want the number of MyObject objects that have the Property Enabled equal to true.

Should define this as a Property or a Method?

In MyList class, should I use:

```<code>public int GetNumEnabledMyObjects(){
    return this.Count(o => o.Enabled == true);
}
</code>```

or

```<code>public int NumEnabledMyObjects {
    get {
        return this.Count(o => o.Enabled == true);
    }
}
</code>```

I looked at Properties vs. Methods in MSDN Design Guidelines and I'm leaning towards a method since it might be considered expensive enough.

Body:
Properties should be used as a shortcut to define getters/setters. Since what you want cannot fit into concept of being a field with only getter, you should define it as a method so that another developer using your class knows that it will cost to call the method.

Another option is defining a real field called NumEnabled and then managing this field as you add/remove objects from the collection. Then you would define it as a property because it is a field now.

If you want to reflect any changes on an instance of MyObject class' Enabled field, then you should define an event that is raised when the object's Enabled value is changed. The collection should subscribe to this event, so that the collection can track when Enabled value is changed for every object in the collection. You can then manipulate the NumEnabled property to reflect any changes made to any object's Enabled field in the list.

class MyCollection<T>
{
    Int32 NumEnabled{get;private set;}

    ...

    void Add(T obj)
    {
        ... // Add the object here
        if(obj.Enabled)
        {
            this.NumEnabled++;
        }
    }

    void Remove(T obj)
    {
       ... // Remove the obj here
       if(obj.Enabled)
       {
           this.NumEnabled--;
       }
    }
}


问:
When should a class or module be in a separate Assembly/DLL?
Are there any guidelines for deciding when a class should be in its own assembly/DLL?  I often see two schools of thought:

1) Every "grouping" of classes belongs in its own DLL e.g. Repositories, Services, DTOs, Infrastructure, etc.

2) Everything should be in a single DLL but separated out via namespaces/folders e.g. have a "Core" DLL with additional namespaces e.g. Core.Repositories, Core.Services, Core.DTO, etc.

At work we just lump everything in a single Assembly called "Business".  There are some folders but there's no real separation - business objects (with logic, some of which shouldn't even be classes) are lumped in a "BusinessObjects" folder without care.  Things used in more than one class are in a "Core" folder.  Utilities are in a "Utilities" folder, the data access infrastructure is a "Data" folder - you get the idea.

For a new module I'm working on I want/need to have a separate data access layer (think a rudimentary Repository implementation) but I don't want to just throw it under the "BusinessObjects" folder with the other 160 (!) classes there.  At the same time I'm concerned about creating a new Class Library since everyone is used to stuffing a class in the single Library; a folder/namespace could work however.

答:
"Uncle Bob" Martin of Clean Code, SOLID Principles fame has outlined three principles here:

The Release Reuse Equivalency Principle: The granule of reuse is the granule of release.

The Common Closure Principle: Classes that change together are packaged together.

The Common Reuse Principle: Classes that are used together are packaged together.

The general rule of thumb is that you should keep the number of projects in your solution as low as possible. Only split them up if you need to do so in order to implement one or more specific user stories, or if having a single assembly is causing measurable performance issues (typically once they get up to several megabytes in size).


问:
Is SourceSafe really safe?
Having spent all morning trying to check something in - I now realise I've lost a couple of days worth of work.

Its happened before - and is apparently common occurrence with SourceSafe.  Can SourceSafe be used successfully, without problems, and if so, how?

答:
After 3 years of using it, complaining off and on to my manager because of all the more advanced/rational alternatives out there, I've never really had a problem with VSS, but I've never had an option either.

My views are that it both sucks and blows.

The most annoying part about it is not it's awful versioning and confusing branching ability, but the list box on the file menu doesn't let you hit the right arrow key to expand.

Truly painful.

Title: Is SourceSafe really safe?

ContentLicense: CC BY-SA 2.5


问:
Are `break` and `continue` bad programming practices?
My boss keeps mentioning nonchalantly that bad programmers use break and continue in loops.

I use them all the time because they make sense; let me show you the inspiration:

function verify(object) {
    if (object->value < 0) return false;
    if (object->value > object->max_value) return false;
    if (object->name == "") return false;
    ...
}
```

<p>The point here is that first the function checks that the conditions are correct, then executes the actual functionality. IMO same applies with loops:</p>

<pre class="lang-bash prettyprint-override"><code>while (primary_condition) {
    if (loop_count > 1000) break;
    if (time_exect > 3600) break;
    if (this->data == "undefined") continue;
    if (this->skip == true) continue;
    ...
}
</code>```

I think this makes it easier to read & debug; but I also don't see a downside.

答:
Yes you can [re]write programs without break statements (or returns from the middle of loops, which do the same thing). But you may have to introduce additional variables and/or code duplication both of which typically make the program harder to understand. Pascal (the programming language) was very bad especially for beginner programmers for that reason. Your boss basically wants you to program in Pascal's control structures. If Linus Torvalds were in your shoes, he would probably show your boss the middle finger!

There's a computer science result called the Kosaraju's hierarchy of control structures, which dates back to 1973 and which is mentioned in Knuth's (more) famous paper on gotos from 1974. (This paper of Knuth was already recommended above by David Thornley, by the way.) What S. Rao Kosaraju proved in 1973 is that it's not possible to rewrite all programs that have multi-level breaks of depth n into programs with break depth less than n without introducing extra variables. But let's say that's just a purely theoretical result. (Just add a few extra variables?! Surely you can do that to please your boss...)

What's far more important from a software engineering perspective is a more recent, 1995 paper by Eric S. Roberts titled Loop Exits and Structured Programming: Reopening the Debate (http://cs.stanford.edu/people/eroberts/papers/SIGCSE-1995/LoopExits.pdf). Roberts summarizes several empirical studies conducted by others before him. For example, when a group of CS101-type students were asked to write code for a function implementing a sequential search in an array, the author of the study said the following about those students who used a break/return/goto to exit the from the sequential search loop when the element was found:

I have yet to find a single person who attempted a program using [this style] who produced an incorrect solution.

Roberts also says that:

Students who attempted to solve the problem without using an explicit return from the for loop fared much less well: only seven of the 42 students attempting this strategy managed to generate correct solutions. That figure represents a success rate of less than 20%.

Yes, you may be more experienced than CS101 students, but without using the break statement (or equivalently return/goto from the middle of loops), eventually you'll write code that while nominally being nicely structured is hairy enough in terms of extra logic variables and code duplication that someone, probably yourself, will put logic bugs in it while trying to follow your boss' coding style.

I'm also gonna say here that Roberts' paper is far more accessible to the average programmer, so a better first read than Knuth's. It's also shorter and covers a narrower topic. You could probably even recommend it to your boss, even if he is the management rather than the CS type.


问:
Is it poor form to use C features such as the size_t type instead of their c++ counterparts, such as std::size_t?
I have recently been told that using size_t as declared in the global namespace is incorrect in C++, ostensibly because size_t is a C-feature. I looked this up and came across this question on Stack Overflow:

https://stackoverflow.com/questions/5813700/difference-between-size-t-and-stdsize-t

The top answer makes it pretty clear that there isn't any real difference between size_t and std::size_t, but that leaves open the question of style and correctness.

Since I'm programming in C++, is it "wrong" to use a C feature such as size_t in place of the slightly longer but no better C++-specific std::size_t?

答:
<stddef.h> is a 100% standard header file in C++, that provides the type ::size_t.

As a bonus it also is standard in C.  Very nice if you're writing a header file for a library with a C-compatible interface, using #if __cplusplus / extern "C" {.

Note that the usual arguments about namespaces and naming collisions don't apply, as the Standard allows inclusion of any or all header files to introduce ::size_t.

The only time that using std::size_t is "better" than ::size_t is if you have not included <stddef.h> (perhaps you have #include <cstddef> instead).


问:
Should a domain object wrap/contain a DTO interface?
Using .NET - I have an interface IPerson.  This interface is implemented by classes in  multiple, separate repositories, e.g. EF6 (EfPerson), custom SQL (SqlPerson), or even custom assembly connecting to a web service (WebPerson).

Assuming rich domain model, my idea is that my lovely rich domain object 'Person' could have a private member variable _PersonDto of type IPerson, supplied via constructor.  The members of Person would be the only way to access data from the _PersonDto.

Q. Is there anything actually inherently wrong with that approach?  (Assume I'm not lazy loading, and that I will possibly have a service layer for cross-cutting stuff).

Please note I'm using DTO here to simply mean the anaemic objects I get back from my repositories.

答:
A couple of observations.

First, classes (DTO or otherwise) should be data-persistence agnostic.  In other words, they should have no awareness of their underlying data persistence mechanism.  It worries me that you have three different versions of a Person that are distinguished only by the way they are stored or retrieved.

Second, DTO classes are merely containers, used primarily for movement of data from one place to another.  The only reason you might set them via constructor is if:

You wanted them to be immutable, or

You wanted them to be valid on instantiation.

Validation in business systems is normally accomplished elsewhere (it shouldn't necessarily be tied to the Person object, although you can annotate objects with validation information), and in business systems, there's generally no expectation of immutability (most business systems are a big mass of mutable data and business logic).

So for all these reasons, I say the answer to your question is no.


问:
What is a class library?
I'm working on a lawsuit and I need a definition of a 'class library' that I can reference. Every book and all the documentation I can find seems to assume the reader already knows what a library is. Even the wikipedia entry on 'Library (computing)' is low on references. And the references it does have are from the 80s or earlier.

So, in the context of C#, what is a class library? (with references)

I have been getting a decent number of definitions from 'Design Patterns: Elements of Reusable Object-Oriented Software' but it also assumes the reader knows what a library is.

答:
From University of Washington School of Law website:

The central programming abstractions provided by object-oriented languages are those of objects and classes. Objects represent real, functioning program entities that contain data and can respond to certain messages. Classes are a means of defining and organizing a world of objects. A class defines the data and behaviors of a group of objects. For example, a programmer may wish to build a student database application for a university. In doing so, she may create a class called Student that defines the relevant characteristics of a student. These characteristics may include data such as name, student ID number, and GPA. They may also contain behaviors that students can perform. For instance, a student might know how to take exams, complain, and ask questions. Finally, classes may relate to each other by means of inheritance. In our example, our programmer might create a subclass of Student called GradStudent that specializes and/or extends the behaviors of Student in some manner. For instance, a GradStudent may prefer to complain about his or her advisor, whereas a generic Student may typically prefer to complain about grades. Inheritance allows the programmer to easily reuse much of the functionality of existing classes, by defining a subclass that overrides certain default behaviors of its superclass. (Some object-oriented languages, C++ for example, use the term base class for superclass and derived class for subclass. For obvious reasons, we shall avoid the use of those terms here.)

In the technology primer (also from University of Washington School of Law), the page also goes into some detail about Software Decomposition. This will give you an easy to understand explanation of what a class is without requiring the legal definition.

Title: What is a class library?


问:
Using commit messages for time tracking
Some products can parse a special syntax in commit messages to extract additional data, such at time tracking information: https://confluence.atlassian.com/display/FISHEYE/Using+smart+commits

To me, this seems like the misuse of one tool to activate a feature on another, but I'm having trouble articulating my reasoning. It seems similar to the process smell of storing issue tracking information in code comments.

Is there anything fundamentally wrong with using commit messages as a time tracking mechanism?

答:
I've seen this feature as well, and am also wary of it. If I were to articulate my reasoning, I would say that it muddies the cleanness and intent of a commit message. When I ask myself, "what is the intent of a commit message?", it is to act as a succint breadcrumb to myself and others about what I was working on and how I tried to make it better.

To that end, a commit message with an issue number is actually a good thing because both I and another programmer could definitely care about that and use it for reference. Having just an issue number with no description is not particularly helpful without the issue tracking tool, so I try to avoid that and still keep at least a short description. Having an issue number even without access to the bug tracker could still help my eye easily pick out related commits.

But time tracking? Six months from now, that will not benefit me or another programmer. Additionally, it will make the commit log look messy.

Title: Using commit messages for time tracking


答:
The term "class library" is an ambiguous assertion that can vary wildly by language, runtime, and convention. Even if we were to limit the discussion only to C#, it would be difficult to find a useful definition as to what is and is not a class library.

The particular features of C# actually make this more complicated, as a "class library" might be a NuGet package, an assembly intended to be used in another program, a collection of *.cs files meant to provide parent or special case classes, or some combination of the same.  Even mere confusing, any of the above could contain more than one "class library", or code that is not part of any "class library".

Since you mentioned a lawsuit, presumably you have some disagreement that hinges on what is and is not a "class library", and the contract in question either did not specify a precise definition or included one that either you or the other party wants to discard.  If such is the case, you likely cannot get out of arguing the definition in court, even if you found a clear and unambiguous definition from the. national programmer's union.

Of course if the definition of "class library" is not material to your lawsuit, just go with an ambiguous definition.  (A group of one or more classes, which may be presented in any form and may or may not be all contained in the same namespace or written in the same language.

Title: What is a class library?

Body:
I'm working on a lawsuit and I need a definition of a 'class library' that I can reference. Every book and all the documentation I can find seems to assume the reader already knows what a library is. Even the wikipedia entry on 'Library (computing)' is low on references. And the references it does have are from the 80s or earlier.

So, in the context of C#, what is a class library? (with references)

I have been getting a decent number of definitions from 'Design Patterns: Elements of Reusable Object-Oriented Software' but it also assumes the reader knows what a library is.


答:
Sometimes it makes sense to have a class hierarchy in which derived classes differ only in implementation methods from base classes.  In particular, if you have a hierarchy of objects that have the same inputs, the same outputs, and interact in identical ways with the rest of the system, but nevertheless have substantially different implementation logic, you can consider using a method-only hierarchy.

For instance, consider CAD software which allows users to add "measurement" objects to its database.  Each measurement entity holds a persistent reference to one or more geometric entities, and outputs a real number (the measurement) in a specified unit system.  Now, there might be many different measurement algorithms -- arc length, max/min radius of curvature or extrema along a vector of selected curves; surface area or perimeter of selected faces; and so on.  Each release of the CAD system is likely to add new measurement types.  But they should all behave identically to the rest of the system.  E.g. if geometric entities are copied and pasted, their measurements should be copied alongside with references updated.  Or if a geometric entity is highlighted, perhaps its measurements should be queried from the database and shown in a window.  As long as there is substantial identical code dealing with the generic aspects of measurement entities, a method-only class hierarchy (probably mirroring an interface hierarchy) is a sensible implementation.

In your case, however, you are creating a top-level class which is the union of other classes with substantially different inputs or outputs, like so:

```<code>public abstract class Top
{
    public abstract double? Sub1Properties { get; }

    public abstract double? Sub2Properties { get; }
}

public class Sub1 : Top
{
    double data = 24.0 // or whatever.
    public override double? Sub1Properties
    {
        get
        {
            return data;
        }
    }
    public override double? Sub2Properties
    {
        get
        {
            return null;
        }
    }
}
</code>```

This, I think is unfortunate.  Consumers of your classes will likely write code like so:

```<code>        if (top.Sub1Properties != null)
        {
            // DO something
        }
        else if (top.Sub2Properties != null)
        {
            // Do something
        }
</code>```

Now imagine that, tomorrow, you need to add a third subclass:

```<code>public abstract class Top
{
    public abstract double? Sub1Properties { get; set; }

    public abstract double? Sub2Properties { get; set; }

    public abstract double? Sub3Properties { get; set; }
}
</code>```

All those if statements will need to be updated.  This is old-time procedural logic, and is IMHO an anti-pattern.  In your case, if you need to add a new dosing regimen (bi-monthly) in a later software release all those if statements would need updating.

In your case, I might suggest dividing up "Medication" and "Dosing Schedule" into separate objects/tables, with each medication having a link to its appropriate schedule.  Then adding a new regimen would require only a new entry in the table.  I might also represent frequencies in a generic way to the outside world, for instance by using a TimeSpan.  If there is substantial logic specific to each regimen, it could be represented as a hierarchy of classes, as long as there is a generic representation to the outside world for all the data therein.

Body:
Sometimes it makes sense to have a class hierarchy in which derived classes differ only in implementation methods from base classes.  In particular, if you have a hierarchy of objects that have the same inputs, the same outputs, and interact in identical ways with the rest of the system, but nevertheless have substantially different implementation logic, you can consider using a method-only hierarchy.

For instance, consider CAD software which allows users to add "measurement" objects to its database.  Each measurement entity holds a persistent reference to one or more geometric entities, and outputs a real number (the measurement) in a specified unit system.  Now, there might be many different measurement algorithms -- arc length, max/min radius of curvature or extrema along a vector of selected curves; surface area or perimeter of selected faces; and so on.  Each release of the CAD system is likely to add new measurement types.  But they should all behave identically to the rest of the system.  E.g. if geometric entities are copied and pasted, their measurements should be copied alongside with references updated.  Or if a geometric entity is highlighted, perhaps its measurements should be queried from the database and shown in a window.  As long as there is substantial identical code dealing with the generic aspects of measurement entities, a method-only class hierarchy (probably mirroring an interface hierarchy) is a sensible implementation.

In your case, however, you are creating a top-level class which is the union of other classes with substantially different inputs or outputs, like so:

public abstract class Top
{
    public abstract double? Sub1Properties { get; }

    public abstract double? Sub2Properties { get; }
}

public class Sub1 : Top
{
    double data = 24.0 // or whatever.
    public override double? Sub1Properties
    {
        get
        {
            return data;
        }
    }
    public override double? Sub2Properties
    {
        get
        {
            return null;
        }
    }
}

This, I think is unfortunate.  Consumers of your classes will likely write code like so:

        if (top.Sub1Properties != null)
        {
            // DO something
        }
        else if (top.Sub2Properties != null)
        {
            // Do something
        }

Now imagine that, tomorrow, you need to add a third subclass:

public abstract class Top
{
    public abstract double? Sub1Properties { get; set; }

    public abstract double? Sub2Properties { get; set; }

    public abstract double? Sub3Properties { get; set; }
}

All those if statements will need to be updated.  This is old-time procedural logic, and is IMHO an anti-pattern.  In your case, if you need to add a new dosing regimen (bi-monthly) in a later software release all those if statements would need updating.

In your case, I might suggest dividing up "Medication" and "Dosing Schedule" into separate objects/tables, with each medication having a link to its appropriate schedule.  Then adding a new regimen would require only a new entry in the table.  I might also represent frequencies in a generic way to the outside world, for instance by using a TimeSpan.  If there is substantial logic specific to each regimen, it could be represented as a hierarchy of classes, as long as there is a generic representation to the outside world for all the data therein.


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

The format is mentioned here: AssemblyVersion - MSDN

答:
A build number is usually incremented at every build so it is unique.

For simplicitys sake, some reset the build number whenever the MAJOR or MINOR numbers are bumped.

Most Continuous Integration engines allow for autogenerated unique build numbers.


问:
Project is nearly done, but procedural spaghetti code. Do I rewrite or just keep trying to ship it?
I'm a beginner web developer (one year of experience).

A couple of weeks after graduating, I got offered a job to build a web application for a company whose owner is not much of a tech guy. He recruited me to avoid theft of his idea, the high cost of development charged by a service company, and to have someone young he can trust onboard to maintain the project for the long run (I came to these conclusions by myself long after being hired).

Cocky as I was back then, with a diploma in computer science, I accepted the offer thinking I can build anything.

I was calling the shots. After some research I settled on PHP, and started with plain PHP, no objects, just ugly procedural code. Two months later, everything was getting messy, and it was hard to make any progress. The web application is huge. So I decided to check out an MVC framework that would make my life easier. That's where I stumbled upon the cool kid in the PHP community: Laravel. I loved it, it was easy to learn, and I started coding right away. My code looked cleaner, more organized. It looked very good.

But again the web application was huge. The company was pressuring me to deliver the first version, which they wanted to deploy, obviously, and start seeking customers.

Because Laravel was fun to work with, it made me remember why I chose this industry in the first place - something I forgot while stuck in the shitty education system.

So I started working on small projects at night, reading about methodologies and best practice. I revisited OOP, moved on to object-oriented design and analysis, and read Uncle Bob's book Clean Code.

This helped me realize that I really knew nothing. I did not know how to build software THE RIGHT WAY. But at this point it was too late, and now I'm almost done. My code is not clean at all, just spaghetti code, a real pain to fix a bug, all the logic is in the controllers, and there is little object oriented design.

I'm having this persistent thought that I have to rewrite the whole project. However, I can't do it... They keep asking when is it going to be all done.

I can not imagine this code deployed on a server. Plus I still know nothing about code efficiency and the web application's performance.

On one hand, the company is waiting for the product and can not wait anymore. On the other hand I can't see myself going any further with the actual code. I could finish up, wrap it up and deploy, but god only knows what might happen when people start using it.

Do I rewrite, or just keep trying to ship, or is there another option that I've missed?

答:
This sounds like every other system that has been thrown at me to fix.

Relax, this happens to a lot of people. A junior thrown in at the deep end with no experience, who has no help, no support and no guidance isn't exactly a recipe for success. Hiring and expecting a junior programmer to build a brand new system from scratch that works well, performs well and is maintainable is not realistic whatsoever. Hell you're lucky if all that happens with a senior programmer.

In my opinion you have to come clean. This will not be fun. Tell them that you've done your best, it works (mostly), but you're worried that it might not perform well and that there will be a lot of bugs (there's always bugs). It needs to be reviewed by a senior programmer, and they should be able to fix any glaring performance/security problems pretty quickly. Or they can deploy it and cross their fingers. It'll either go ok, or go up in smoke. Maybe you can fix problems as they come up. If you have a large user base maybe not.

Or you could do what most people do in this situation: take the money, disappear and let them sort it out. I'll leave it up to you to work out what the ethical choice is.

Edit (as this question has a lot of votes I might as well add some more content)

Part of the joys of being a programmer is that non-technical people (probably your manager, definitely the rest of the business) have no idea what you do. This is both good and bad. Part of the bad is that you have to constantly explain how software development projects work. Planning, requirements, code reviews, testing, deploying and bug fixing. It is your job to explain the importance of testing, and to set aside time to test. You have to stand your ground here. People won't understand the importance ("can't we just start using it?") but once they start testing (not in the live environment!) they will quickly understand the benefits. One of the reasons why they hired you is because they don't know anything about software development, so it's up to you to educate them. You need to emphasize the importance of testing and bug fixing here - remember, they are not programmers, they don't know the difference between a divide by zero and a broken html tag.

Often a lot of the problems that crop up aren't actually bugs. They will be usability issues, missed requirements, requirements that have changed, user expectations (why can't I use this on my mobile?) and then the actual actual real bugs. You need to iron these out before you go live - often a lot of bugs can be worked around or fixed a few days later. If people expect a perfect system they're going to be in for a lot of pain. If they are expecting bugs your life will be a big easier over the next couple of weeks.

Oh and don't confuse user testing with unit testing nor with system testing.

Unit Testing - does my code function return the right value

System Testing - does it throw an error when I click on X

User Acceptance Testing (UAT) - does the program conform to the requirements? Does it do what they asked you to make it do? Can it go live?

If you haven't written down the requirements of what they asked you to do, UAT will be much, much more difficult. This is where a lot of people fall down. Having what they wanted the system to do written down on paper will make your life a lot easier. They will say "Why doesn't it do X?" and you can say "You told me to make it do Y". If program is wrong, fix it. If the requirements are wrong, fix the doc, ask for an extra day or two (no, insist on it), make the change, update the documentation and re-test.

Once you've gone through this process a few times you can start looking into Agile.. but that's another world :)

TL;DR
Testing is good


问:
Does this kind of programming language exist?
I'm thinking about creating my own pet programming language, and I have been wondering if similar language already exists.

The basic idea is that the language itself would be dynamically typed with strong metaprogramming capabilities (think Ruby). But instead of running it directly, it would be interpreted/expanded into another language, that would be statically typed, with static data structure and minimal dynamic dispatch (think C). This would then be compiled to machine code. The expansion could happen before running the program or during it's deployment, and all necessary libraries would be part of it, instead of each library being expanded separately.

Before I start working on it, I would like to know if anything like that already exists. So I can either inspire myself or drop it, because it would be useless work.

答:
LLVM has a C backend, though it may or may not be in active development.

As C is more or less a platform-independent, just above assembly language language, making it the target of a compiler is not exactly the worst idea in the world, and a number of programming languages have done exactly that.

asm.js is a proof of concept.  It's a low-level subset of Javascript that is specifically designed to be a compiler target.

See also http://en.wikipedia.org/wiki/Source-to-source_compiler


答:
Compile-time metaprogramming is a thing, if that's your doubt. The only question is whether you do it well (as in, convenient and comprehensible but still powerful enough to be useful). The compile-time code can by typed in any way you like (or not at all) but if at the end of compilation the program is fully statically typed you'd be hard-pressed to sell it as dynamic language for various social and technical reasons.

However, in this domain you need to carefully distinguish compile-time code and run-time code at all times. If the dynamic typing creeps outside of the metaprogramming and into the runtime logic, you're halfway down the road to hell that is trying to compile dynamic typing away.

RPython is usually presented as a subset of Python, but in reality it's very close to what you propose (just otherwise specialized for writing VMs). Arbitrary Python code is imported (which in Python entails running the code) and can use the full metaprogramming capabilities, then the resulting object graph (modules, class objects, function objects, constants) is analyzed, typed and compiled down to C. It's not without its share of problems though, some of which may be alleviated if the "source language" is designed for this work flow (e.g. permits type annotations).

Title: Does this kind of programming language exist?

Body:
I'm thinking about creating my own pet programming language, and I have been wondering if similar language already exists.

The basic idea is that the language itself would be dynamically typed with strong metaprogramming capabilities (think Ruby). But instead of running it directly, it would be interpreted/expanded into another language, that would be statically typed, with static data structure and minimal dynamic dispatch (think C). This would then be compiled to machine code. The expansion could happen before running the program or during it's deployment, and all necessary libraries would be part of it, instead of each library being expanded separately.

Before I start working on it, I would like to know if anything like that already exists. So I can either inspire myself or drop it, because it would be useless work.


问:
How specific should be an interface about its implementation details?
Perhaps I should have picked a better title, but anyway...

Basically what to do with two or more implementations that have the same public interface, but they are meant for slightly different purposes having a slightly different behavior?

For example let's say a proxy class that uses the same public interface of the original class but with important changes in its behavior.

```<code>interface MyTest
{
    getSomething() : MySomething;
}

interface MyTestImmutable (extends MyTest ?)
{
    // same interface, but in this case the following method
    // is supposed to return a clone of the stored MySomething instance
    getSomething() : MySomething;
}
</code>```

Thanks

答:
The point of interfaces is to hide the implementation differences between different ways of achieving the same visible result.

In my view, if two methods do the same thing, but one is slow and reliable while the other is fast and unreliable, or if one returns a clone and the other always returns the same object, etc., then those are not the same things. They should more often be two different methods on the same interface. You can express the degree of relatedness by choosing similar names,  e.g. something like getProbablePrime(int bits) vs. getPrime(int bits), but if the difference is something that the caller has to take into account, then you shouldn't hide it.


答:
Interface design should be primarily governed by the need of the user, not capabilities of the implementation. And the user does not want to care about the implementation details. Code using the interface should be able to use either implementation without special-casing for "variants" of the interface.

If on the other hand there are disjoint sets of users for each implementation, they probably shouldn't be using the same interface. They can't use the other implementation anyway, so they can just use the concrete type and YAGNI applies to having an interface at all.

If there is code that may use either and some code that only works with one implementation, than the interface should only cover the needs of the universal code and the specific code should use the concrete classes. Or subinterfaces if there is still some genericity. Or desire to mock the implementation for tests (It often isn't worth mocking each and every class, just those that interact with outer world. And not always even those. I rarely mock anything as in my domain it is usually easier to just prepare suitable environment for the tests).

Title: How specific should be an interface about its implementation details?

Body:
Perhaps I should have picked a better title, but anyway...

Basically what to do with two or more implementations that have the same public interface, but they are meant for slightly different purposes having a slightly different behavior?

For example let's say a proxy class that uses the same public interface of the original class but with important changes in its behavior.

```<code>interface MyTest
{
    getSomething() : MySomething;
}

interface MyTestImmutable (extends MyTest ?)
{
    // same interface, but in this case the following method
    // is supposed to return a clone of the stored MySomething instance
    getSomething() : MySomething;
}
</code>```

Thanks


答:
Take 2.

I understand that you have the following constraints:

You can't change the underlying data model on the server at all.  The server-side representation of "MedicationEntity" has hardcoded fields corresponding a small number of possible sets of dosing schemes, and you need to be able to translate from & to this model.

The various dosage schemes can't be generalized as a set of standard time intervals.  E.g. "M, Th, S" might be a valid weekly dosage schedule.  This lack of perfect uniformity kills the idea of representing all the frequencies as a simple TimeSpan.

In that case, I would suggest that your "MedicationEntity" class should completely hide the server-side dosage frequency fields.  It must needs remember them internally, since that is what is stored on the server, but it should never present them as public properties.  Instead it should have some property "DosageFrequency" which returns an instance of a class implementing an interface "IDosageFrequency" (here I am using c# because I am most familiar with it):

```<code>public interface IMedicationEntity
{
    string Name { get; }

    double Dose { get; }

    string Units { get; } //

    IDosageFrequency DosageFrequency { get; set; }
}
</code>```

The "IDosageFrequency" interface could encapsulate all the business logic for each dosage frequency and present them in a neutral manner, e.g.:

```<code>public interface IDosageFrequency
{
    string Name { get; }

    string Description { get; } // Localized for presentation in the user interface.

    string FormattedPromptString(IMedicationEntity medication); // E.g.: string.Format("{0} {1} of {2} three times a week.", med.Dose, med.Units, med.Name)

    DateTime NextDoseTime(DateTime now);

    TimeSpan DoseTimeRequiredAccuracy { get; }

    IEnumerable<DateTime> DoseTimesBetween(DateTime start, DateTime end);

    // etc
}
</code>```

You could then implement this interface with different classes corresponding to each basic dosage scheme.  You could also use the abstract factory pattern to maintain libraries of standard DosageFrequency objects to present in the user interface, to allow end users to select a new dosage scheme for some pre-existing or new medication.

This would leave you with only two nasty switch statements, both inside your "MedicationEntity" class:

Constructing the appropriate IDosageFrequency from the stored fields from the server, AND

Selecting the appropriate server fields when a new IDosageFrequency object is set.

By hiding the sever-level hardcoded dosage schemes, this pattern (is there a name for it?) could keep the switch statements from growing out of control while also avoiding the need to create different medication class types for different dosage schemes.

Update: incidentally, I just noticed a potential pitfall with your scheme of creating a class hierarchy for the "MedicationEntity: objects.  If you need to implement the ability to change the dosage scheme for a pre-existing MedicationEntity, you will need to immediately locally replace the existing MedicationEntity with an instance of a different subclass, e.g. DailyMedicationEntity -> WeeklyMedicationEntity; if you didn't you would be unable to locally work with the new settings.  But the server side representation of the MedicationEntity would not need to be deleted and recreated, which means you temporarily could have obsolete, replaced MedicationEntity instances floating around in your client referring to still-extant database entities.  This, I suspect, might Cause Problems.

Body:
Take 2.

I understand that you have the following constraints:

You can't change the underlying data model on the server at all.  The server-side representation of "MedicationEntity" has hardcoded fields corresponding a small number of possible sets of dosing schemes, and you need to be able to translate from & to this model.

The various dosage schemes can't be generalized as a set of standard time intervals.  E.g. "M, Th, S" might be a valid weekly dosage schedule.  This lack of perfect uniformity kills the idea of representing all the frequencies as a simple TimeSpan.

In that case, I would suggest that your "MedicationEntity" class should completely hide the server-side dosage frequency fields.  It must needs remember them internally, since that is what is stored on the server, but it should never present them as public properties.  Instead it should have some property "DosageFrequency" which returns an instance of a class implementing an interface "IDosageFrequency" (here I am using c# because I am most familiar with it):

public interface IMedicationEntity
{
    string Name { get; }

    double Dose { get; }

    string Units { get; } //

    IDosageFrequency DosageFrequency { get; set; }
}

The "IDosageFrequency" interface could encapsulate all the business logic for each dosage frequency and present them in a neutral manner, e.g.:

public interface IDosageFrequency
{
    string Name { get; }

    string Description { get; } // Localized for presentation in the user interface.

    string FormattedPromptString(IMedicationEntity medication); // E.g.: string.Format("{0} {1} of {2} three times a week.", med.Dose, med.Units, med.Name)

    DateTime NextDoseTime(DateTime now);

    TimeSpan DoseTimeRequiredAccuracy { get; }

    IEnumerable<DateTime> DoseTimesBetween(DateTime start, DateTime end);

    // etc
}

You could then implement this interface with different classes corresponding to each basic dosage scheme.  You could also use the abstract factory pattern to maintain libraries of standard DosageFrequency objects to present in the user interface, to allow end users to select a new dosage scheme for some pre-existing or new medication.

This would leave you with only two nasty switch statements, both inside your "MedicationEntity" class:

Constructing the appropriate IDosageFrequency from the stored fields from the server, AND

Selecting the appropriate server fields when a new IDosageFrequency object is set.

By hiding the sever-level hardcoded dosage schemes, this pattern (is there a name for it?) could keep the switch statements from growing out of control while also avoiding the need to create different medication class types for different dosage schemes.

Update: incidentally, I just noticed a potential pitfall with your scheme of creating a class hierarchy for the "MedicationEntity: objects.  If you need to implement the ability to change the dosage scheme for a pre-existing MedicationEntity, you will need to immediately locally replace the existing MedicationEntity with an instance of a different subclass, e.g. DailyMedicationEntity -> WeeklyMedicationEntity; if you didn't you would be unable to locally work with the new settings.  But the server side representation of the MedicationEntity would not need to be deleted and recreated, which means you temporarily could have obsolete, replaced MedicationEntity instances floating around in your client referring to still-extant database entities.  This, I suspect, might Cause Problems.


答:
Whenever you start from scratch, you'll almost certainly make the same amount of mistakes or more due to the Second System Syndromme. Your new mistakes will be different, but the amount of time needed for debugging will be similar and so will despair about how it's not a good fit. It will also delay deployment into production or deployment of new features if the first version is deployed, which will be serious trouble for the company. Joel Spolsky calls it "single worst strategic mistake" that any company or developer can make.

The recommended approach is instead to clean the initial mess bit by bit during maintenance. And don't even try to refactor it just for the sake of it. Besides, managers usually see that as waste of money (which it often is) and it brings unnecessary risk of introducing new bugs. Once you painfully debugged the code, it may not be pretty, but it will work. So let it be until you need to touch it for other reasons (be it a bug fix, new feature or just a change requested by marketing). Then clean up the parts that are most difficult to adjust. This is often called the Boy Scout Rule.

And at that point you don't have to argue it with the manager. Just include the minimal desired refactoring in the estimate for the request. You'll learn through experience when you may afford to yield a bit because the company is really in a fix and when you don't want to create problems in future and just don't admit any possibility of quickly hacking it.

Last, one more bit of recommended reading: the Big Ball of Mud.

Title: Project is nearly done, but procedural spaghetti code. Do I rewrite or just keep trying to ship it?

Body:
I'm a beginner web developer (one year of experience).

A couple of weeks after graduating, I got offered a job to build a web application for a company whose owner is not much of a tech guy. He recruited me to avoid theft of his idea, the high cost of development charged by a service company, and to have someone young he can trust onboard to maintain the project for the long run (I came to these conclusions by myself long after being hired).

Cocky as I was back then, with a diploma in computer science, I accepted the offer thinking I can build anything.

I was calling the shots. After some research I settled on PHP, and started with plain PHP, no objects, just ugly procedural code. Two months later, everything was getting messy, and it was hard to make any progress. The web application is huge. So I decided to check out an MVC framework that would make my life easier. That's where I stumbled upon the cool kid in the PHP community: Laravel. I loved it, it was easy to learn, and I started coding right away. My code looked cleaner, more organized. It looked very good.

But again the web application was huge. The company was pressuring me to deliver the first version, which they wanted to deploy, obviously, and start seeking customers.

Because Laravel was fun to work with, it made me remember why I chose this industry in the first place - something I forgot while stuck in the shitty education system.

So I started working on small projects at night, reading about methodologies and best practice. I revisited OOP, moved on to object-oriented design and analysis, and read Uncle Bob's book Clean Code.

This helped me realize that I really knew nothing. I did not know how to build software THE RIGHT WAY. But at this point it was too late, and now I'm almost done. My code is not clean at all, just spaghetti code, a real pain to fix a bug, all the logic is in the controllers, and there is little object oriented design.

I'm having this persistent thought that I have to rewrite the whole project. However, I can't do it... They keep asking when is it going to be all done.

I can not imagine this code deployed on a server. Plus I still know nothing about code efficiency and the web application's performance.

On one hand, the company is waiting for the product and can not wait anymore. On the other hand I can't see myself going any further with the actual code. I could finish up, wrap it up and deploy, but god only knows what might happen when people start using it.

Do I rewrite, or just keep trying to ship, or is there another option that I've missed?


答:
You have stumbled on the achilles heel of most CS educations: they teach you the tools and techniques, but not the trade. Building software is a craft, one which you only acquire through years of practice and the experience of having your software used (users are much harsher critics than teachers). Building software is also quite often a business, one where the business goals may override the technical ambitions.

First of all, ship. If you show the business owner the software, and they feel it's ready to ship, then ship. If it's not to that point, but close, finish it. The only software that matters is that which is actually used. The only software business which earns money is one which has a product.

Secondly, you have learned a lot of valuable things, so you should appreciate the experience for what it has taught you:

Slinging code without a plan or architecture is a recipe for disaster

There is much more to programming than writing code

Non-technical business owners often do not understand the impact of technical decisions (like who to hire), and it is up to the developers to explain things to them.

Most problems are already solved much better than you would solve them, in existing frameworks. It pays to know the frameworks that exist and when to use them.

People fresh out of school assigned to a big project with little guidance tend to produce a bowl of spaghetti code. This is normal.

Here is some more advice for you on how to proceed:

Communicate, communicate, communicate. You must be very open and frank about the state of the project and your ideas on how to proceed, even if you're unsure and see multiple paths. This leaves the business owner the choice on what to do. If you keep knowledge to yourself, you deprive them of choices.

Resist the temptation of the full rewrite. While you are rewriting, the business has no product. Also, a rewrite rarely turns out as good as you imagined it. Instead choose an architecture and migrate the codebase to it gradually. Even a horrible codebase can be salvaged this way. Read books about refactoring to help you along.

Learn about automated testing / unit testing. You have to build up confidence in the code, and the way to do that is to cover it with automated tests. This goes hand-in-hand with refactoring. As long as you don't have the tests, test manually and comprehensively (try to break your code, because your users will do so). Log all the bugs you find so you can prioritize and fix them (you won't have time to fix all bugs, no software ships bug-free in the real world).

Learn about how to deploy a web application and keep it running. The book Web Operations: Keeping the Data On Time is a good start.


问:
How to operate a computer without an operating system?
How a computer can be used when there is no operating system?

What tools or knowledge do I need to do it?

Do I have to give all the commands in binary to use computer hardware resources like a monitor?

答:
In case of no operating system you have to program the processor directly using a language it understands. This doesn't mean the CPU only, but others as well, like graphics card processors, sound card processors, etc. Each processor has some kind of basic language it can understand called an instruction set. Instruction sets vary between processor models and consist of memory addressing, flow control, logic and arithmetic instructions. Higher level operations are made up from these basic instructions. The code written using instruction sets is called a machine code.

From there you get to assembly languages, which are again specific for a given processor architecture and usually map strongly to processor instructions. These make writing the code easier for humans and are already considered programming languages, albeit low-level. Assembly code gets translated to machine using an assembler.

So these two are what you need to know to start programming computers directly. Learn the instruction set and assembly language of the specific processors at hand and how to build meaningful operations using these basic instructions. You can build some complex stuff using an assembly alone, including graphics programs, e.g. see http://www.floodyberry.com/asm_toys/.

From there it starts to get wrapped up in layers, all of which provide abstractions and APIs over the lower level: higher level languages, drivers, kernels, OSs and frameworks all the way up to client applications. All of this higher level code translates to machine code in the end, using compilers and interpreters, so that the processor can understand what to do.


问:
Why don't languages include implication as a logical operator?
It might be a strange question, but why there is no implication as a logical operator in many languages (Java, C, C++, Python Haskell - although as last one have user defined operators its trivial to add it)? I find logical implication much clearer to write (particularly in asserts or assert-like expressions) then negation with or:</p>

```<code>encrypt(buf, key, mode, iv = null) {
    assert (mode != ECB --> iv != null);
    assert (mode == ECB || iv != null);
    assert (implies(mode != ECB, iv != null)); // User-defined function
}
</code>```

答:
Python has an implication operator in a sort of hidden way.

The less-than-or-equals operator is overloaded to accept boolean values. As a result, one can use it as an implication operator.

Proof by Example (Python Code):

```<code>print (False <= False) # This will print True.
print (False <= True)  # This will print True.
print (True <= False)  # This will print False.
print (True <= True)   # This will print True.
</code>```

Recall the truth table of the implication operator is:

```<code>LEFT RIGHT RESULT
F    F     T
F    T     T
T    F     F
T    T     T
</code>```

Body:
Python has an implication operator in a sort of hidden way.

The less-than-or-equals operator is overloaded to accept boolean values. As a result, one can use it as an implication operator.

Proof by Example (Python Code):

print (False <= False) # This will print True.
print (False <= True)  # This will print True.
print (True <= False)  # This will print False.
print (True <= True)   # This will print True.

Recall the truth table of the implication operator is:

LEFT RIGHT RESULT
F    F     T
F    T     T
T    F     F
T    T     T


答:
You can be pretty certain that nothing quite like that exists. The question is, though, how close would some other language have to be before it would convince you to give up?

Most languages are defined by a community of users. Users take up a language because of its features, capabilities and community and you can be sure no community would develop around a language that was defined simply by its implementation technology.

Many languages are created as pet projects or as academic works. If one exists you can be sure no-one here has ever heard of it, so no joy there either.

If we consider just languages that compile into a C back-end, there have been many. C++, Objective-C and Eiffel come immediately to mind, but there are many more.

If we broaden your target slightly from C back-end into statically-typed back-end then it includes the JVM and CLR. There are heaps of languages that compile to those targets, and both JVM amd CLR intermediate code can be compiled into assembly language (think Hotspot and JIT).

So depending on exactly how you delineate your question, the answer could range from none to lots and lots. Not an easy question to give a firm answer.

So finally I would observe that questions about 'name that specific product/language/technology' are not a good match for P.SE, as you would doubtless know. Perhaps you could consider that if you decide to continue with this project and are looking for more help.

Scheme is an example of a dynamically-typed language with good meta-programming which can be compiled into C and other statically typed back-ends. It has a strong community and my guess is you've already heard of it. Whether it is a close enough match to the proposal to make you abandon your project is not for me to say.


问:
What is the underlying mechanism behind va_list and where is it defined?
http://www.cplusplus.com/reference/cstdarg/va_list/
According to the above link, va_list is an argument or parameter used in some macros - va_start, va_arg, va_end. These macros are present in the stdarg.h file.

I know that va_list can hold multiple values but what kind of an entity is va_list? My question is what is the underlying mechanism behind va_list? How is it able to hold multiple values? (For example, an array can hold multiple values and the mechanism behind it is multiple memory locations referenced by subscript values. Array is a predefined data structure present in C.)

My second question is where is va_list defined?

答:
The answer to your question is here: https://stackoverflow.com/questions/4958384/what-is-the-format-of-the-x86-64-va-list-structure

The va_list type is an array containing a single element of one
  structure containing the necessary information to implement the va_arg
  macro. The C deﬁnition of va_list type is given in ﬁgure below

```<code>typedef struct {
   unsigned int gp_offset;
   unsigned int fp_offset;
   void *overflow_arg_area;
   void *reg_save_area;
} va_list[1];
</code>```

va_list is defined in stdarg.h as http://www.cplusplus.com/reference/cstdarg/va_list/ states.

You can refer to the book "The Standard C Library" by Plauger if you need to know the ins and outs of the std libc.

Body:
The answer to your question is here: https://stackoverflow.com/questions/4958384/what-is-the-format-of-the-x86-64-va-list-structure

The va_list type is an array containing a single element of one
  structure containing the necessary information to implement the va_arg
  macro. The C deﬁnition of va_list type is given in ﬁgure below

typedef struct {
   unsigned int gp_offset;
   unsigned int fp_offset;
   void *overflow_arg_area;
   void *reg_save_area;
} va_list[1];

va_list is defined in stdarg.h as http://www.cplusplus.com/reference/cstdarg/va_list/ states.

You can refer to the book "The Standard C Library" by Plauger if you need to know the ins and outs of the std libc.


答:
You may want to look at Julia.

It's a modern, dynamically typed language with Lisp inspired meta programming.
It also JIT compiles using LLVM. The standard library is written in Julia too and is compiled and cached on first use I.e. A form of install time AOT compilation.
As the LLVM IR is statically typed, I think this has most of the features you were looking for although, as with many dynamic languages, REPL usage was an important consideration hence the JIT compilation.

One interesting paper I saw (section 5.2). The standard library has around 135k variables of which about 80k had a fixed, static type. The rest had to stay represented as the variant type Any.

Depending on why you're interested in dynamic to static, this may be of value when you look at how dynamic you make your language. Obviously, this has some bearing on performance although, in practice, Julia seems quite quick.


问:
Web-app filtering information client-side vs server-side?
I have a web-app that provides data (that is updated on an interval) for intranet users, who are able to filter information by location.

I was having a discussion with a co-worker about whether that filtering should take place on the client vs server side. The amount of information isn't large, but the users are typically interested in a certain location.

My question..Is it preferable to let the database filter the data and send the results to the client, or return all data back to the client and then sort by location? If it's not clear cut, when would you choose on method over the other?

答:
Some client side filtering issues:

Cache invalidation. Server side filtering will always operate on up-to-date data, while client caches will have to be updated when data changes. This may be very complex depending on which correctness guarantees you want to have. The future developer will curse this solution. If it doesn't work properly the customers will curse this solution.

Query language. Your server already supports SQL out of the box (assumed because of the "sql" tag), and it is very different from JSON + JavaScript, the most obvious candidate for a client side querying solution. There might be a sufficiently generic client side data structure + querying solution out there that you can slap it onto the web site with barely any effort, but the alternative is invariably going to result in more (and more complex) code than using server side querying. The future developer will curse this solution.

Code change propagation. Many web sites have fallen into a trap with client side code where a refresh of the page does not download the latest code. Users then will likely not be able to query until they clear the browser cache. The customers will curse this solution.

Network transfer size. You may have a small database right now, but transferring all of it to every client on a regular basis is going to be quite slow and costly in the long run. The sysadmin will curse this solution. Any customers on slow connections will curse this solution.

CPU/battery use. JavaScript uses more CPU (and therefore battery) than plain text. And no, you will not have the resources to optimise the code. Customers with laptops and slow machines will curse this solution.

If your database really is small, and you create a server side filtering solution which is anywhere near sane, the filter round-trip time should be in the low milliseconds. This is fast enough that nobody will notice, and you avoid a whole lot of extra complexity and possible grief.


答:
There are at least a couple different things that I could imagine the build number referencing:

Source control version that was release.  For example if there was a release of revision #12345, this may be tracked by having it be the build number and if it is patched that is where revisions may go up as it isn't new functionality that would increase the major or minor versions and the build number has to be remembered in case someone wants to run that build again.

Continuous integration server Identifier.  In this case, the CI server may number each build it runs and thus the build number is what a successful build gets and the revision part isn't needed in this scenario.

There may be others that I don't know, but these are the big ones that I know when it comes to numbers on code bases.

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

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

The format is mentioned here: AssemblyVersion - MSDN


问:
Pros and cons for choosing between different return types
This is in context of a client-server architecture, although I don't think the architectural setting is needed to put up the problem.

I have a function whose output can be classified into different categories:

```<code>function makeCar() { /* make a car */ }
</code>```

Now, in order to decide the structure for the return value of makeCar, I have several options:

Option 1

Return integer values and have a data structure that maps the integer values to different types of cars.

Example:

```<code>    codeToCar = {
                 "1": {
                       "model": "Jaguar XJS",
                       "color": "Black",
                       "year": "1975"
                      },
                 "2": {
                       "model": "Chevrolet Camaro",
                       "color": "Blue",
                       "year": "1966"
                      }
                 ...
                }
</code>```

In this case, the function makeCar would return the keys of codeToCar.

Option 2

Return the car object itself and do away with the integer codes.

Option 3

Return a hybrid structure with some integer codes and some specific values.

Example:

```<code>    codeToColor = {
                   "1": "Black",
                   "2": "Blue",
                   ...
                  }

    codeToMaker = {
                   "1": "Jaguar",
                   "2": "Chevrolet",
                   ...
                  }
</code>```

In this case, the function makeCar could return

```<code>   {
    "color": 2,
    "maker": 1,
    "model": "Camaro"
   }
</code>```

What are the pros and cons of using the different options?

Edit:

I guess I should have elaborated the context more. So basically the function makeCar executes on a client browser and the return value of the function is passed to the server in an HTTP request. Any representation for the return type of makeCar on the client side would ultimately be translated to a full object representation (option 2) on the server.

The two parameters I chose for comparing between the different options are:

Number of bytes transferred over HTTP

Extensibility in case new properties are added to cars or new values are added to an existing car property.

I, however, would also be interested to know what other parameters could be used (in the current context) to compare the options available, alongwith choosing between the different options based on the chosen parameters.

答:
Definitely not use #1 because then you need far too many codes to represent all possible configuration of cars

If you want to use 3, then you need to develop a standard to translate between the code and the actual naming strings. This would work well for many real word problems as there are already many well-established standards for things like colors, company ids, etc... This can also work when the users want more control and want to develop their own identification frame.

If you use 2, then you make things more free-form which would suit best for the case where the standards have not become well-established, many conflicting standards, you don't want to develop the standards, you don't want to user to develop the standard that would restrict them in the future. Especially fitting when the data is only used on the surface (such as display string) with minimal business logic depending on it.

In other words, choose 2 or 3. You need to specify your problem more. I would personally lean to ward 3 from what you have put here.


问:
Reliable secure data exchange between service written on .NET and an iOS client app
I have a service written on .NET working on a company server. It designed to do a very simple thing, to receive a request via WCF named pipes from another service working locally on the same server, process it and send a response through named pipes back. Request an response are just a fairly small, XML formatted text.

And now I need to couple it somehow with our in-house iOS application to do the same thing but with a remote connection through internet. I'm not all too experienced with an Objective-C iOS development and not sure how to proceed. I was considering adding a TCP endpoint to the same WCF service but then I'm not sure how reliable will it be plus I'll have to use some sort of encryption "manually" on both ends of the connection.

I can extend or change code of both .NET server and Objective-C iOS client as much as I need but I'm not sure how to ensure reliability and most of all security of data transfer between server and client.

Right now I'm considering rewriting my service part to be a web based app since it works at request-response principle anyway but what would be the best approach? Would it be possible to consume a WCF HTTPS endpoint with an iOS client effective enough?

答:
You should be able to consume an HTTPS endpoint in your iOS app, but I can't give you more info since I don't have experience with Objective-C (although I did work on a project where one of the team members had a similar task).

As for the WCF service, you may not need to rewrite it: decorate your interface with the [WebInvoke]/[WebGet] attributes. Deploy a TCP endpoint if you really need it, but pushing data over HTTP should work just fine, especially since you'll be delivering compact text payloads.


答:
This isn't specific to return types, you're just asking how to represent a car. The answer depends on what properties of cars you need to represent, how those properties vary, and what you actually do with a car once you have it.

There is no absolute, perfect way to represent physical objects: you're always choosing some abstraction, and the choice depends on what you're trying to achieve. So, the answer would be different for a driving game, from a physics simulation, or an inventory or stock control system.

If you have very few possible cars, then an index into a hard-coded array might be fine. If your cars need to be modifiable (eg, changing the colour), an index is unlikely to be a good choice.

If your cars are just inventory items and don't have any behaviour, then a flat list of properties is probably fine. If they have to do something (like drive) then maybe each distinct model could be a subtype, but the colour could still be a (mutable) property.

Title: Pros and cons for choosing between different return types

Body:
This is in context of a client-server architecture, although I don't think the architectural setting is needed to put up the problem.

I have a function whose output can be classified into different categories:

```<code>function makeCar() { /* make a car */ }
</code>```

Now, in order to decide the structure for the return value of makeCar, I have several options:

Option 1

Return integer values and have a data structure that maps the integer values to different types of cars.

Example:

```<code>    codeToCar = {
                 "1": {
                       "model": "Jaguar XJS",
                       "color": "Black",
                       "year": "1975"
                      },
                 "2": {
                       "model": "Chevrolet Camaro",
                       "color": "Blue",
                       "year": "1966"
                      }
                 ...
                }
</code>```

In this case, the function makeCar would return the keys of codeToCar.

Option 2

Return the car object itself and do away with the integer codes.

Option 3

Return a hybrid structure with some integer codes and some specific values.

Example:

```<code>    codeToColor = {
                   "1": "Black",
                   "2": "Blue",
                   ...
                  }

    codeToMaker = {
                   "1": "Jaguar",
                   "2": "Chevrolet",
                   ...
                  }
</code>```

In this case, the function makeCar could return

```<code>   {
    "color": 2,
    "maker": 1,
    "model": "Camaro"
   }
</code>```

What are the pros and cons of using the different options?

Edit:

I guess I should have elaborated the context more. So basically the function makeCar executes on a client browser and the return value of the function is passed to the server in an HTTP request. Any representation for the return type of makeCar on the client side would ultimately be translated to a full object representation (option 2) on the server.

The two parameters I chose for comparing between the different options are:

Number of bytes transferred over HTTP

Extensibility in case new properties are added to cars or new values are added to an existing car property.

I, however, would also be interested to know what other parameters could be used (in the current context) to compare the options available, alongwith choosing between the different options based on the chosen parameters.


问:
Why is C++ "this" poorly designed?

For every a and b which are non-const pointers of the same type, you can do a = b;, right?

Inside non-const member functions the this keyword exists, which is a non-const pointer. So logicaly if b is same type as this you can also do this = b; right?

Wrong.

You cannot do this = b;, because this uses pointer syntax but logically this is a reference!

But why on earth is this syntactically a pointer but logically reference?

Can this weird behavior be corrected in the next C++ standard, by introducing a new keyword, for example me which will be a reference not only logically but also syntactically?

(See also my attempt to solve this here: "Is it a good idea to "#define me (*this)"?")

答:
this is (like nullptr)  a constant pointer; the pointed data is const if and only if this appears in the body of a const member function.

You cannot change a constant pointer, like you cannot change a constant literal like 23.

So assignment to this like

```<code>this = p;  // WRONG
</code>```

is prohibited for the same reasons assignment to nullptr is forbidden:

```<code>nullptr = 0; // wrong
</code>```

ContentLicense: CC BY-SA 4.0

Title: Why is C++ "this" poorly designed?

Body:
this is (like nullptr)  a constant pointer; the pointed data is const if and only if this appears in the body of a const member function.

You cannot change a constant pointer, like you cannot change a constant literal like 23.

So assignment to this like

this = p;  // WRONG

is prohibited for the same reasons assignment to nullptr is forbidden:

nullptr = 0; // wrong


问:
How to make a good bug report for a bug that does not appear on every user?
I found a bug on my XFCE and some other can't repeat the bug, namely https://askubuntu.com/questions/495947/a-logo-disappear-in-xubuntu . How should I report it to the developers if those can't repeat is as well?</p>

答:
The fact that they can't reproduce it shouldn't bother you. Since you can, you report the bug as is, telling exactly what you did to reproduce it, and what is your system.

Then:

Either there is an actual bug affecting many people, in which case there are chances that either somebody else will reproduce and confirm it, or developers will look at the code and find that indeed, there is a problem with it,

Or the bug affects only you or a very small amount of users (for example users who installed a specific version of a specific software product while having a specific driver for a specific device and a specific system file missing), in which case, there are risks it will never be solved.

Reading closer your linked question, it seems that:

The problem is too minor: it doesn't look like this problem impairs your ability to use the OS properly. I'm pretty sure there are many currently opened bugs which will have a higher priority than this one.

The problem might be related to your GPU, in which case it affects only people using the same GPU or type of GPU, which highly reduces the number of potentially affected users, thus reducing the chances for this bug to be solved.

But still, create a bug report, explain what you do to reproduce the problem, just like you did in your linked question, and specify the version of the OS, the drivers you have installed, etc.

Note: if you can actually reproduce a bug on a virtual machine, this could help a lot: you will then be able, for example, to share the virtual machine with the developers, in order for them to actually see the issue.


答:
Yes, there are versions of Lisp and Scheme that will compile to C (and have been for at least 25 years!) Specifically Gambit Scheme has had a C back end since the early 90's that will compile to C, from which you can build into binary code on pretty much any platform.

As scheme is a lisp it features a very strong ability to do meta programming. In fact you can in general rewrite the entire language if you want to. Lisps are in general also dynamically typed. So It could well be that scheme will do everything you want

And of course God write in Lisp: https://www.youtube.com/watch?v=5-OjTPj7K54


问:
What's the worst question you were ever asked at interview?
It doesn't have to be programming or software development related, but just asked during an interview for an IT related job.

I know some "left field" questions are meant to see how the candidate copes with unexpected and novel situations, but here I'm looking for a question that appeared to be completely unrelated to the job they were interviewing you for, or something that made you think "what useful information could they possibly get from my answer to that question?".

答:
Are you easily offended by off-color humor?

Is there anyone who thinks they are?  If I define it as humor, then I'm probably not offended, and if I'm offended, I probably didn't think it was funny or humorous.  Obviously, there are things that WOULD offend me, but I have no way of knowing if what you refer to and what I refer to are the same degree of offensiveness, and no way of asking if that's what you refer to without bringing up, by definition, an offensive topic!

It occurred to me after a few seconds that they might want to just see how I react to interoffice disputes or something, but that question threw me off for a second.