instruction stringlengths 34 19.9k |
|---|
I am building a program which would have WCF support. I am using the MVC pattern. For each controller there is a WCF service class. e.g. I have CTRL.CTRLBooking, WCF.IWCFBooking and WCF.WCFBooking.
For each controller (total of 10) there is a WCF class and an endpoint.
Is this a good approach or should I keep all the m... |
I have been trying to design a library to do some simple geometric computations in an Euclidean space regardless of its dimension. While it is easy to represent points, vectors, hyperspheres and hyperplanes in a generic fashion, I am still unable to find a generic way to represent a (infinite) line, even though lines s... |
I have always wondered about this, especially in C/Java style languages. For example, consider the first 3 lines of this C# code:
lock (serviceLock)
using (var client = new ServiceClient())
try
{
// Do something
client.DoSomething();
}
catch (System.ServiceModel.FaultException ex)
{
// Handle error
add... |
This question is asked many times, and I always prefer code-first as I like to keep the logic in code.
But now I have a challenge to load screen under 5 seconds and very little time to do things.
I have large set of records, and I'm possibly going to retrieve them asynchronously.
There are a few doubts in my mind.
D... |
Our teamlead said that many files much worse than a single, despite of we are working on a big project.
He argued that our customers could more easily send logs to us if there will be just a single file.
To understand our log-file he wants to develope our own log-analyzer which will analyze a single log-file separating... |
Our team is developing an application using WPF with MVVM.
We want to make ViewModels reusable. With this intention we want to abstract the transition logic between Views (ViewModels, we use ViewModel-first approach with Caliburn.Micro) so the other application can override it.
For instance, we have App1 and App2. Firs... |
I am fairly new to using patterns and although I understand some of them to a point I find it difficult to work out which one(s) to use in a particular situation.
I am trying to wrap up an existing db schema into a number of objects and am not sure if I should simply be using inheritance or a mixture some patterns
I ... |
Let's start with the problem:
There is a large dictionary X that contains {key, value} pairs, i.e.:
X = [{100, 10}, {101, 0}, {103, 0}, {106, 2}, {110, 1}]
Every t seconds, X has to be updated with values from sub dictionary U and 0 set to each value for a key that is not present in new updated U, but was in the previ... |
The Java team has done a ton of great work removing barriers to functional programming in Java 8. In particular, the changes to the java.util Collections do a great job of chaining transformations into very fast streamed operations. Considering how good a job they have done adding first class functions and functional... |
I'm integration testing a system, by using only the public APIs. I have a test that looks something like this:
def testAllTheThings():
email = create_random_email()
password = create_random_password()
ok = account_signup(email, password)
assert ok
url = wait_for_confirmation_email()
assert url
ok = accou... |
I intuitively think that an application should be exactly the same in DEV, QA, and PROD environments. However, I have been asked to add a feature to an application that will only be available in DEV environment.
I have a server and database for each environment - dev, test, and production. I want to know if there woul... |
For example, if I wanted to generate some HTML based on some input. Which is the preferred way out of:
<?php
function generate_html($type, $input){
switch($type){
case 'paragraph':
//Generate and return the HTML code for a paragraph
break;
case 'ul':
//Generate a... |
I have a 3 layered application.
Presentation Layer (PL): ASP.NET MVC app
Business Logic Layer (BLL) project
Data Access Layer (DAL) project
I need to add a Web Reference to a service for a payment gateway. Where does it go? PL or BLL?
P.S.
Before using the Web service I need to retrieve some data from database and ... |
I want to present a list of products to the user. This list is paginated and can be sorted by the user by product ID or product name in ascending or descending order.
I am using an MVC setting, where I would like to query the database in the model.
How would I write functions that query the database? I can think of sev... |
I have a piece of code that composes method name to call from a string parameter. I don't feel it's a good thing to do but I'm not sure what can go wrong with this.
Here is a simplified snippet of that code:
switchToFilter = function(filter){
var filterMethod = 'switchTo' + filter;
myObject[filterMethod]();
}
|
Java has the following syntax for different bases:
int x1 = 0b0101; //binary
int x2 = 06; //octal
int x3 = 0xff; //hexadecimal
Is there any reasoning on why it is 0 instead of something like 0o like what they do for binary and hexadecimal? Is there any documentation on why they went this route?
|
I was reading a thread and saw this post, which says that Javascript is faster than Jquery because it uses native code. But why is the use of native code faster? Is this always the case? What impediments does Jquery have in performance?
|
So I have a program whose purpose is to take text files and parse them into a binary format that an embedded system understands. However, the text format I've inherited that I need to parse is sufficiently complex enough that after refactoring the main parse routine I'm left with a class with more than 50 methods that... |
I need to analyze data uploaded from vehicle GPS devices to detect travel patterns and then attempt to learn about the normal travel patterns for that vehicle so that predictions can be made about maintenance, refueling etc. Some vehicles are domestic (exhibiting normal home->work->home travel patterns) and some are co... |
Let's say I wanted to start an open source project that I hope/expect to have many people submit patches and whatnot. Is it viable to take a strict TDD approach? Can/should I expect/trust collaborators to write quality tests whenever they submit a patch?
One thing I've been thinking about is writing test suites for ind... |
In one of the projects (in C), I have the code that looks like this (the names are obfuscated specially for question to not give out details of the probject):
typedef struct Module_s {
/* These fields are parsed by f1() */
S1 *s11;
S2 *s12;
size_t n11;
size_t n12;
int i11;
/* These fields a... |
I am using Singleton pattern for my application, I have used ADO.NET Entity framework as my Data Access Layer, after login to my application, it's taking 3 to 5 minutes to load the dashboard.
Is there a way to reduce the time? Or I have to look for some other methods instead of Entity framework?
|
I have been tasked with producing a plan for implementing a slight change to the work of our developers (there are eight of us working at this company). The change affects a small portion of our work, but introduces a new tool that the developers aren't familiar with, and a new "step".
Very schematically the change lo... |
I recently ran into an error, I guess caused by my lack of understanding of how HTTP works, where I was sending a JSON object to the server to be stored in session data, and then sent back to the client at a later time.
When I was sending the data to the server all of my booleans were enclosed in quotes and so when th... |
Is it perfectly legal to use GHC as base and build some commercial application over its top ? Are there such examples I can can interact with ?
|
I'm using FogBugz for Project Management, and I'm unsure how to structure my cases.
I have different features which require implementing as part of this project.
For example, if I have a new feature to include autocomplete on a search text box, this would have cases such as:
Method for returning search terms
Front-end... |
Many naming conventions recommend that methods returning a boolean (also called predicate methods) should be named after a question. My question is: don't they really mean the methods should be named after an assertion?
The difference may be subtle, but you end up with different names in some cases:
question: is_pixel... |
I have been tasked with writing a print driver. I have no experience with this and have been researching it for a few days. The goal of this is to essentially write the data coming to the driver to a file and then do some additional processing of it.
If I understand it correctly, I can start other processes to do mos... |
At the moment, we're using sql server full text search, but it's too inflexible.
The main thing we do is look up names of people from a database based on a search query. The searches need to be fast, and they need to be fuzzy. SQL Full Text Search doesn't really support fuzzy matching especially when combined with the ... |
I'm working on a windows form to calculate UPC for item numbers.
I successfully create one that will handle one item number/UPC at a time, now I want to expand and do it for multiple item numbers/UPCs.
I have started and tried using a list, but I keep getting stuck. I created a helper class:
public class Codes
{
pr... |
I'm a Mac user, but I need to write a script on Windows, and I'm not sure how I should go about that.
Here's the scenario:
Someone adds photos to a USB drive. The drive is then inserted into a digital picture frame.
In order for the photos to autoplay, a 'playlist.asb' file must be present on the drive. I want to creat... |
I am working with a non-OO language and I'm trying to name my routines consistently. I came acrross the following guideline from Steve McConnell's Code Complete:
To name a procedure, use a strong verb followed by an object
McConnell gives the following good and bad examples:
good, non-OO --> PrintDocument(doc)
good,... |
I have a team that works on multiple technologies. I want to know how can I automate the process of code review for .Net, .Net MVC, Python, PHP, Drupal and HTML5/CSS with JavaScript.
I have read about and have used some tools like StyleCop/FxCop for .Net and PHP Code Sniffer and likes for PHP and pyLint for Python.
I u... |
My company recently started doing formalized code reviews. The process goes like this: you submit into a github, request a pull request, code gets reviewed by approximately three people, then if all passes, your code goes in.
The process seems fair, however the three people who do the code reviews don't seem to be fair... |
Admittedly new to this but I wanted to understand why there is a gap between Red Hat's JBoss EAP project (their enterprise version) and JBoss AS/Wildfly/community project.
Looking at this post from Red Hat, it seems that they don't withhold the source/patches. Makes sense since withholding the source would be a GPL vi... |
I'm sometimes suppsed to demo work and I wonder if the Scrum methods have specified something about how demos should be done? I've done quick demos and I've been asked to demo on-the fly while it's not realistic to expect that programming always moves only forward. SO I'd like to know if you can tell me since I follow ... |
I am currently developing a new library for RESTful web requests in Puredata, and am about to release version 1.0.0. This version will not implement all HTTP verbs, only GET, PUT, POST and DELETE.
In the next version, this library will most likely include the other HTTP verbs for RESTful requests, PATCH, HEAD, OPTIONS,... |
For a software, I have two different branches, that only differ in using different library versions of a package, that my software uses. The API of this library has changed between the versions in a non-compatible way.
I am currently developping using both versions with the identical functionality in different branche... |
Single responsibility (from SOLID) is like making me create classes with only one public method. But if it's so, it would be possible use static methods, and go back to procedural programming. What's the difference?
|
Let's say I have a model that has 'purchase' method. The purchase method should take care of purchasing a product.
Signature of purchase
public function purchase($token, Model_Member $member, Model_Product $product, Model_Recipient $recipient);
To call this method, I need to make $member, $product, and $recipient in m... |
When I'm looking at questions asked on sites like stackoverflow on how to make a particular piece of code "more pythonic" there are usually suggestions offered to use complex list comprehensions or generators or other python features that aren't available in, say, Java.
I am a casual Python programmer, and sometimes I ... |
While working to build software products for early stage startups, I have seen two very common schools of thought that define an approach to application design.
Those 2 paradigms typically include designing an application predicated on an "extendible codebase” or a "throw away codebase".
What factors should one consi... |
Background:
I am familiar with xUnit family frameworks and have had experience with (shunit2, PhpUnit and simpletest). I am currently trying to find a testing framework for C++. I did a quick search for frameworks using Wikipedia's list of documented frameworks; however, the framework I would like to use is very diffic... |
This may or may not be a silly question, but I really would like to know the answer to something which has been bothering me for a while.
I quite often see programming examples/conventions where the programmer has created a directory called acme to put stuff in.
What does Acme mean? Why Acme and not Emca or other?
Is A... |
In my case joining table inside subquery or outside subquery gives very few difference with COUNT
CASE 1: about 6202 rows.
In this case table_c is joined inside subquery, but is only joined (No other actions for the table, not selecting any data or filtering whole query with that table).
CASE 2: about 6235 rows.
In th... |
I'm currently trying to cover our shopping cart with unit tests.
Class ShoppingCartItem has property Term. It also loads available terms for this item upon object creation. Currently this is done using call to static class in constructor.
Current state:
public class ShoppingCartItem
{
private Dictionary<Guid, Shopp... |
I'm using Visual Studio 2010 to amend a C# project.
Part of the application requires the user to be able to save and read a settings file (1 Project reads them in (as read only) from a file. The other project reads them in from the file to be shown in the GUI and when saved, the file is to be overwritten).
If both of... |
I'm trying to design a small web platform that would host several "applications", with a common user pool. My reflection is now focused on the authorization system.
I define an application as an interface that allows users to perform CRUD and more custom operations on a set of resources. I tend to prefer to model an ap... |
I have an interface Serializer with methods serialize and isSerializerFor. I created a first implementation of this using TDD, and ended up with a nice clean test case fully covering a nice clean implementation. To get a more concrete idea, here is one relevant commit.
Now someone else (who is not used to doing TDD) st... |
I am building a Comparator that provides multi-column sort capability on a delimited String.
I am currently using the split method from String class as my preferred choice for splitting the raw String into tokens.
Is this the best performing way to convert the raw String into a String array? I will be sorting millions ... |
I have an exercise in Python as follows:
a polynomial is given as a tuple of coefficients such that the powers are determined by the indexes, e.g.: (9,7,5) means 9 + 7*x + 5*x^2
write a function to compute its value for given x
Since I am into functional programming lately, I wrote
def evaluate1(poly, x):
coeff = 0... |
I am starting to design the database schema for the eCommerce element of a web service I am creating.
The thing I'm trying to get my head around is how to deal with the use case of a seller (user of my web service) deleting a product.
The issue I have is that this product could be referenced in a customers basket, to b... |
I have some objects that will be created an entered into the database. There is no guarantee that any of their fields will be unique except for the auto-incrementing primary key. I would like to be able to access these objects later in the program using their primary key.
What is the best way to get this key out of the... |
This breaks nothing (in my experience), but lots of things "don't break anything" and are still wrong.
#! /usr/bin/env python
"""Short description of this module."""
def preferred_exit_method(*args):
#code for exiting as desired
try:
import foo
import bar
import eggs
except ImportError as e:
#code... |
When unit testing I often find myself debating how much of the data I feed to, and expect back from my units under test, I should include in the actual test files.
The tradeoff I constantly struggling with is:
If a large portion of the test (in code volume) consists of input and output data, it seems difficult to act... |
I have been a Rails developer for a year now, and I really want to start diving in to Ruby and pure programming without using a framework. However I am having trouble conceptualizing little programs I can build on my own. I guess it's because I'm so used to having a GUI (the web browser) to interact with the classes th... |
Firstly I would like an answer from an experienced person (not a one man band), someone whom has worked in a medium/large team and had to battle with this burning question before.
The problem:
I am constantly being asked to not submit empty rows
by rows = I mean a list of items and properties.
A good example would be,... |
Take from wikipedia, aliasing is defined as accessing a data location through different names.
Also taken from wikipedia, indirection is defined as referencing something "using a name, reference, or container instead of the value itself". Am I missing something here - Are these two one and the same? If not, how are the... |
I was recently tasked with building a Name Entity Recognizer as part of a project. The objective was to parse a given sentence and come up with all the possible combinations of the entities.
One approach that was suggested was to keep a lookup table for all the known connector words like articles and conjunctions, remo... |
I am a .NET developer who has recently started working in a LAMP environment. I know that if I go to www.somedomain.com/files/test.php, then (1) DNS resolves the URL to my server (2) my server handles the request on a given port (3) the server looks in /files/test.php and somehow runs test.php and returns the output of... |
I recently created a version of Snake, the classic game popularized by Nokia, and I am planning on using it as an example of my game development skills. I just want to know if there are any copyright issues that could come up if I do this?
|
I am senior developer/architect who knows the business domain really well.
My new manager wants me to manage a team (yet to recruit of around 5 people) and in the past I have worked in an agile environment but as a developer. So I was involved in the writing user stories, working with stake holders, estimating via stor... |
I've just started writing unit tests and I'm not sure am I doing it the "right way." Should I test every class "by removing dependencies"? In other words, does unit testing mean: "test part of a code with assumption that provided dependencies to other modules are correct and test these dependencies as single modules la... |
I want to create a lookup table for this data:
The "input variables" (what is used to "lookup") are 4 different doubles that can each take on 1 of 200 numbers (the numbers range from 1-1000 but there are only 200 possible numbers that each can be (these 200 possible numbers that each of them can be are known to me)) th... |
A block is a list of statements to be executed. Examples of where blocks come up in C are after a while statement and in if statements
while( boolean expression)
statement OR block
if (boolean expression)
statement OR block
C also allows a block to be nested in a block. I can use this to reuse variable name... |
I've been reading about D and Go and how they aim at being compiled to machine code yet be convenient (like garbage collection, no need to manipulate pointers unless needed) and I agree that there is a need for such a language. However designers of both Go and D for some reason decided to invent a new language. Why? Wh... |
I am developing a game in JavaScript where you start with a user input, stored in the variable "controller". The options for the user consists of start to start the game or about to learn about the game. I was going to use the following code
if(controller === "start"){
// Game code sitting here
}
else if(controller... |
I'm working with a team building a RESTful web service, and our current implementation utilizes the user's email as a unique identifier for the user resource, yielding URIs like the following:
https://www.domain.com/users/example@gmail.com/resource
Emails are guaranteed to be unique in our system, and we've handled whe... |
Does putting the view logic inside the controller increase page load speed? Because I have a controller action calling a view which I am loading through ajax and I am getting a very slow response. Why is that happening?
Does putting the view logic inside controller like...
echo "<div>View echoed</div>"
a good way to ... |
I am currently writing a transformation from model space to clip space for use in OpenGL. From what i have seen, programmers typically use a traditional rectangular frustum to define the clipping boundaries in their model space. I personally had in mind a shape like a frustum, except the near and far planes are spheres... |
Suppose we are in a distributed environment, and mutual exclusion is not implemented yet. So how would we be able to detect race conditions?
When I researched, use of non-blocking algorithms was found as a solution. That is using datastructures like stack, queue, etc. So that we could avoid mutual exclusion.
But how do... |
I am currently working on an application (basically its a kind of execution engine capable of running user defined jobs and generate output in real time) that needs to handle rollback functionality, it might sound crazy but is it possible to have such thing at the application level? e.g. imagine some user tries run a j... |
Why did the team at LMAX design the LMAX Disruptor in Java but all their design points to minimizing GC use? If one does not want to have GC run then why use a garbage collected language?
Their optimizations, the level of hardware knowledge and the thought they put are just awesome but why Java?
I'm not against Java or... |
Question title can be a little confusing but I didn't have a better way to put to put it.
In Java you can have this:
JLabel HoHoHo = new JLabel();
...
HoHoHo.setText("Ho Ho Ho");
And this:
JLabel HoHoHo = new JLabel("Ho Ho Ho");
In both cases, it gives a label with Ho Ho Ho on it.
Question
How is that possible? I me... |
I'm looking at a very large (5-6 digit LOC), very complex, code-base, full of interacting bulky, interdependent, views and stored procedures (multiple 4-5 digit count silos).
The source SQL has been touched many times, by many different people, and no formatting constraints have been enforced. This led to wildly differ... |
I've been working in an application with about 100k LOCs and basically We have been reworking features to comply with a new architecture based on a new technology stack. This work is almost finished but we had to keep the old code because we had to guarantee a stable environment in case of critical bugs in the new .
Th... |
Would simply using AWS to build an application make this application a distributed system?
For example if someone uses
RDS for the database server,
EC2 for the application itself and
S3 for hosting user uploaded media,
does that make it a distributed system?
If not, then what should it be called and what is this applic... |
I have two objects, one is a User object and the other is a Content object. The User object has properties like 'reads_articles' or 'reads_books'. The Content object has properties like 'is_article' or 'is_book'. If the two properties match up (i.e. the User reads_articles and the Content is_article), then the User can... |
I'm writing a semi-automatic scheduling application. Given some existing bookings and some resource requirements, it needs to find the times at which a new event can be scheduled. A human user will then evaluate the results and choose one of the options. It does not need to optimise a timetable for multiple events and ... |
We are a team of 8-10 developers working on different parts of a Sitecore instance. In the past we've used SVN and more recently (and successfully) Hg, but are moving to using Git as our primary source control. We're working with Sitecore 7, and using the latest TDS from Hedgehog. In case it matters we're also using th... |
Why is it that the IEEE 754 standard provide 8 bits for the exponent but puts a range maximum of 38 on the largest acceptable exponent?
Seems kind of ridiculous to have the data storage there but not allow it to actually be used.
I wanted to pack data into this exponent for some encoding I'm doing, but I can't use all ... |
Why is there no exponentiation operation in hardware, even though many languages have builtin operators for it?
Is it because even hardware implementations would need to use the same algorithm as software (i.e. no hardware implementation could be significantly more efficient), or because it is rarely used, or another r... |
In quite many assemblers, a value copying instruction is usually named "MOV" and its description in manuals usually also contains "move" (however, other words can be used, like "load", "store", "extract", etc.) It's uncommon to find an ISA ) which doesn't follow this convention.
On the other hand, in other contexts, "m... |
Suppose I have a list of objects sorted by a person based on that person's subjective taste. Let's assume that this person is being somewhat consistent in their sorting and that there are quantifiable attributes of these objects that I can identify. For example, a person might sort cheese based on how much they enjoy t... |
I've been a Rails developer for a year now (originally self taught), and am at the point where I want to improve. I've been reading books on how to improve the quality of my Ruby code (I read Design Patterns and Practical Object Oriented Design in Ruby).
I'm trying to improve the quality of my code and to add to my po... |
I have my enum like this.
enum Size{PAGE_SIZE=20,
HEADER_SIZE=30
};
I only use them as constants(No enum variable created) in my program.
i.e= int x = PAGE_SIZE + 20;
So what is the better way to declare the constants in this scenario? (enum or const)
|
I've never built a RESTful API before and I am wondering how discrete should it be?
For example lets say I have a customer which has a name, address, phone number, email address, language, etc.
Does it make sense that there is a way to update each individual field (update address, update email address, etc), or should ... |
I'm working (slowly) on a small Flask project. One of my models is a class called Post, which is a lightweight namedtuple. Post objects are created by a PostFactory, because creating a Post involves hitting a database. The PostFactory holds the necessary database connection, so the Post objects can be serialized.
What... |
When you have to iterate a reader where the number of items to read is unknown, and the only way to do is it to keep reading until you hit the end.
This is often the place you need an endless loop.
There is the always true that indicates there must be a break or return statement somewhere inside the block.
int offset ... |
What would be a good use case to use a native XML database such as Apache Xindice and eXist-db? I have used XML features of SQL Server in the past and they were of great value, but there it is possible to use XML for 5% and traditonal storage for 95% of the application. Which application types would benefit from a 100%... |
Most functional programming languages such as Scheme and Haskell use lists as their main data structure. Queues are identical to lists, except for the fact appending to the end - not to the begin - has constant time. Every algorithm that is written elegantly using lists with head and tail can be written elegantly using... |
Is there any special reason that to construct list in Scheme you use
(cons 1 (cons 2 (cons 3 nil)))
instead of
(cons 3 (cons 2 (cons 1 nil)))
? While the first seems more obvious because it reads in the right order, the second is the one which actually reduces in the right order. Also, it seems more natural to const... |
Where should you manage a users session in a SOA? Should you manage it in the Web Service or in the client and why?
My application is SPA
(Considering that this will be the stacked that will be used
Apache CXF for Web Services
AngularJS for making REST calls)
|
Many dekstop apps have this, such as dropbox (windows version). You right-click the dropbox systray icon and there are shortcuts to the features of the main app.
Right now, I want to keep it simple and just want to run a exe(?) and have a custom icon appear in the system tray notification area. How do I build this?
|
I am a beginning programmer and I was recently working on some primitive GUI apps in Java.
That's where I encountered different layout managers. I browsed the web and it says that for advanced GUI creation there are NetBeans and Qt and a lot of other stuff.
My question is:
Do I really need to learn all ins and outs of ... |
I've heard that methods are more Object-Oriented than functions. I was wondering if someone could show me an example of a function and a method and explain the differences between methods and functions?
I have taken 3 quarters of Java programming and functions have never been mentioned, I want to know the differences,... |
class A { public: int i; }; // A.h and defined in project libA.vcxproj (libA.dll)
I'm using class A in multiple places at various projects as below. Apporoximately 100 projects.
include "A.h"
class UseA { public: A *a; UseA(){ a = new A(); } ~UseA() {delete a;} }
My problem is whenever I add a member variable to clas... |
I have identified a couple of open source projects on github.com that are not being kept up to date for many months. I have used them for personal use, and now want to make enhancements to them and start maintaining the code base and write sample clients that use these projects. I've sent pull requests to the authors a... |
I have a method to be tested which depends on the OS, what's the best approach for testing the method depending on the OS? Is it to test on every OS that I have I require? Is there a better approach for running the tests on only one system?
Some more specific information is that I have a method which is dependent on t... |
The guidelines discuss the service layer with its service interfaces and data/message/fault contracts. They also discuss the business layer with its logic/workflow components and entities as well as the 'optional' application facade.
What is unclear still to me after studying this guide is where the implementations of ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.