instruction stringlengths 34 36.1k |
|---|
I'm building a model of the SQL query language.
It doesn't attempt to abstract SQL at all - instead, it tries to model it directly, so it has model objects named Query, Table, Column, Variable, Expression, Join, etc.
Contrast this with an object/relational mapper, which tries to abstract away SQL and the DBMS in favor ... |
Say I have a large class called Root, which has a lot of members & functions:
class Root {
public:
void func1(); // operates on a and b
void func2();
...
private:
A a;
B b;
C c;
...
};
The class Root is getting a bit big so I decide to factor out a few of the member variables and a ... |
If I have an algorithm A. and it has fewer instructions than algorithm B. but performs worse on a CPU due to poor memory coalescing (and hence, poor CPU cache performance), does that factor into the Time Complexity analysis - given that, CPUs can have different wildly different cache implementations (or no cache) such ... |
I am the beginner to AngularJs. Finding difficult to understand the concept of ng-model.
I have a controller with $scope.statusPickList=["Planning" "Execution" "Closed"];
How this has to be used in the template(html file) in the < Select> statement? Can anyone please help me to understand?
I am trying the below < Sele... |
I've stared to work on developing larger applications, and am struggling to adjust around non-instant builds. Before I would make a small change, then build and test that change. This doesn't work so well when building + unit tests take several minutes. Any suggestions?
Edit - The suggested duplicate is about how to de... |
In languages like C and C++, while using pointers to variables we need one more memory location to store that address. So isn't this a memory overhead? How is this compensated? Are pointers used in time critical low memory applications?
|
From my (admittedly limited) exposure to functional programming languages, such as Clojure, it seems that encapsulation of data has a less important role. Usually various native types such as maps or sets are the preferred currency of representing data, over objects. Furthermore, that data is generally immutable.
For e... |
You can say this is opinion based, but the problem is that everyone's opinion on this issue is same.
Even the lead developers say that creating the threads is easy, dealing with them together is difficult. It isn't a newbie's job.
All I know is that to deal with threads you have to lock all shared data till each thread... |
I'm trying to understand why UML is not used in most free software projects. For example, my Debian/Linux system has probably more than ten thousand free software packages, and I cannot name even one which has been developed using explicit UML framework and methodology. For example, Qt, GCC, Linux kernel, bash, GNU mak... |
I have a Map which takes in an a String key, and an array of custom objects as the value. the map usually contains two entries, and the arrays for both entries never change in terms of data; once they are populated(one, for example, is an array of 50 state objects) they do not change. I have been following the practice... |
I'm writing a medium size OOP application in C++ as a way to practice OOP principles.
I have several classes in my project, and some of them need to access run-time configuration parameters. These parameters are read from several sources during application start-up. Some are read from a config file in the users home-... |
Background
My web application lives on a centralised server in the product's "network", and provides the means to manage/configure various distributed devices. The server also logs various statistics that arrive from each device, storing them on disk in /var/log/. The web GUI allows users to download those logs.
It als... |
The definition of a deadlock is when two or more threads cannot complete their execution because they are mutually blocked and waiting for something from the other thread(s).
Is there a similar term for when two or more threads take a long time to finish, rather than never finish, because they're waiting for another th... |
I've taken over some code at work that has a database repository file that keeps stored procedure names in constants. The file looks like this:
class DatabaseRepository
{
private const string SP_GET_EMPLOYEES = "GetEmployees";
private const string SP_GET_DEPARTMENTS = "GetDepartments";
private const string... |
What is the problem that is solved by Domain Driven Design?
I understand what Object Oriented Programming brought and see the issues it addressed and how, and in what aspect/scenaria, it made the live of a developer easier. But I so far failed to see the big picture of what DDD does bring us. For sure this is due to th... |
We are a low budget team working on a web app. Due some complications we might need to work remotely from January and onward. After some consulting and googling, we concluded that several small repositories is the cheaper option. We're thinking in:
Backend and services
Middleware
Front End
This way we can separate ... |
I am writing a server-client program with the following idea (analogy for my real program). There are many types of shapes. The client represents the shapes to the user which can queue operations (like translation, rotation...) on them. The client sends the server the id and operation type. The server performs the oper... |
I'm reading up on event sourcing and can't stop asking myself if it only makes sense in exotic situations where writes are very rare or military-grade auditing is required.
A non-exceptional system with any significant usage might produce between hundreds and thousands of writes per day, translating to, say, a million ... |
Reading Mary Rose Cook's Practical Introduction to Functional Programming, she give as an example of an anti-pattern
def format_bands(bands):
for band in bands:
band['country'] = 'Canada'
band['name'] = band['name'].replace('.', '')
band['name'] = band['name'].title()
since
the function d... |
Suppose I have a sorted array which contains n integers.
How do I find subset of size k such that the minimum distance between all pairs of integers in the subset is maximized, I mean they are at maximal distance.
example: array a[]={1,2,6,7,10} and k=3,
subset = {1,6,10}, the minimum distance is 4 between 10 and 6.
Wr... |
So, yes, diagrams can be inappropriate at times. When are they inappropriate? When you create them
without code to validate them, and then intend to follow them. There is nothing wrong with drawing a diagram to
explore an idea.
Agile Software Development: Principles, Patterns, and Practices - Robert C. Martin
Wh... |
I am currently working on an application, which will show several messages (alarms - warnings - hints) on a cable-connected display.
As these messages depend on several indicators I have to decide when to show (one or more indicator fit) or to hide (no indicators fit) them. For the first implementation I use a sort of... |
I'm reading Martin L. Abbott, Michael T. Fisher's Scalability rules: 50 principles for scaling Web sites, and in rules 24 and 25 they talk about Application Caches and Object Caches respectively.
My previous understanding was that an Application Cache, let's say ehCache, it's a layer that you put between your services ... |
How would one go about designing classes for a system in which two components depend on each other?
For a more concrete example, consider this scenario, you're designing a piece of software to manage students, teachers and classes in an educational facility. For convenience purposes, you'd like your Class object to be ... |
We have "copy constructor" but "clone method". This asymmetry in naming puzzles me -- does anyone know for what reason the method was not named "copy" (and interface per analogy "Copyable")?
This question is about historical process of Java language design, and the choice that was made, not current opinion which one is... |
In a multi client server application, I need to know when each client connection is dead on the server side.
After set keep-alive for client (and change default time from 2 hours to 10 second) each client could know when disconnected from server, but on the server side, Java doesn't have any method to set keep-alive li... |
However, in cases where the tests did not force the separation, and the smells of Rigidity and Fragility become strong, the design should be refactored using
the Facade or Proxy patterns to separate the two responsibilities.
From : Agile Software Development: Principles, Patterns, and Practices
I understand how Facad... |
I am developing a COM addin for Microsoft Excel, using VB.Net. I wrote a class to represent a worksheet that contains certain elements. Let's say for example it has a ListObject. I create a property for the ListObject like this:
Public Class MySheet
Private myTable as Excel.ListObject
Public Property Table() As Excel.... |
I know there are questions about calling the base method inside an overridden method such as this. But what if an overridden method only calls the base class? Is this bad/good deign? It just seems odd, why override a method just to call the base anyway?
For example see:
public class BaseClass
{
virtual public void ... |
Where trying to improve the "confidence" we have in our inter-service communication.
Background:
"Contracts" has been a matter of sharing a piece of code that defines an interface to implement, but over the years, the shared code changed, and a lot of different implementations (soap, msmq, rest etc.) sprouted up, whic... |
We are now in the process of switching from svn to git (after a year spent on convincing people, yay!) in my company.
So far, this is all for the better but there is one little thing that we currently have in our workflow that I can't find a good equivalent too.
Currently, all our developers work in master. Once every ... |
Suppose I have MasterPackage containing a Master class, and BlasterPackage containing Blaster class. Since Master needs a Blaster to work, the higher level MasterPackage depends directly on lower-level BlasterPackage.
Using classic Dependency Inversion, one would add IBlaster (or AbstractBlaster) to MasterPackage, thus... |
I have a shared user repository (id, name, e-mail, password, etc.) exposed as a REST service - and multiple independent websites accessing this REST service (from the back-end) as a means of sharing a common user base across multiple sites.
I have a local, in-memory event bus (pub/sub) as part of the REST server implem... |
So I have a sets of numbers representing some timings.
This is how they look like:
[sec] [msec]
100 75
100 200
101 60
101 233
102 255
104 21
First column contains the elapsed seconds, and the second one the elapsed milliseconds. Values are represented using 8bit (so if the ms number is bigge... |
I want to synchronise the local database of mobile devices with the server's database. This synchronisation will happen for example when user comes online, to update the local as well as the remote database with possible changes.
I thought about 2 approaches and already implemented 1 of them, but it's quite complicated... |
So, my Business Code needs some Objects.
It does not know how much objects it needs and it does not know the exact types (because polymorphism is involved).
For me, that sounds for a good reason to go factory pattern.
My code now looks like:
std::vector<AbstractBaseClass*> objectList;
Factory f;
objectList = f.create("... |
The specific example I have in mind is javax.servlet.ServletResponseWrapper:
public class ServletResponseWrapper implements ServletResponse {
private ServletResponse response;
/**
* The default behavior of this method is to call setCharacterEncoding(String charset)
* on the wrapped response object.
... |
I've seen a number of questions, like this, asking for advice on how to store enums in DB. But I wonder why would you do that. So let's say that I have an entity Person with a gender field, and a Gender enum. Then, my person table has a column gender.
Besides the obvious reason of enforcing correctness, I don't see why... |
Inspired by this SO question, I'd like to better understand the contract defined by Runnable, along with when it is and is not acceptable to use the Runnable interface. We know that Runnable's most common use-case is to be implemented by a class that is intended to be executed on a separate thread:
Runnable task = () -... |
A project I am working on currently models Order information. Right now, there is one class with a bunch of properties and functions that all of orders have in common. In addition, some of our users have customized properties and/or functions on top of the base order. Some of those customized properties are shared betw... |
I am in charge of rewriting some old VB code. I understand how it works, but I feel like there is a far-more efficient way to do what they did. I just can't figure out what it is. Here is a contrived example that in terms of data requirements is really similar to what I need to do.
The user has to pick out the manufact... |
In C#, you register an event like:
window.onClick += myHandler;
But why use this instead of a "register" method that takes your handler and registers it. E.g.:
window.registerOnClick(myHandler);
The += counters my intuition for at least two reasons:
Couldn't somebody use = to eliminate past registrations? But more g... |
Is it best practices to never alter the contents of a Collection that is passed as a parameter?
I want orgSet to only have words. But, sometimes there are one char strings (like question marks, commas, etc.) that I want to remove from the set of words. These are not the full methods, but it makes my point:
public stat... |
Currently, I have this hybrid mobile application which talks to my C# web service to do CRUD transactions. As the mobile application is always on the go, and there might not have internet connectivity in all situations.
Therefore, I'm thinking of using SMS transactions in offline mode.
For Login:
Using sms, communicat... |
I made a login system with access rights (ASP.NET WebForm) and I store the info's in a database table. I don't use the built in feature of asp.net like Forms authentication and webconfig. My question is, am I doing good?
I check from the database table if a certain user has access to a certain web page and if not I red... |
I was reading about delegates and events on this webpage to get a better understanding of them and how they relate to each other. While reading, I came across this statement:
That goes against the principle of locking on privately held
references to avoid accidental deadlocks.
The author was referring to a lock wi... |
I'm new to Angular JS and working on a project with "legacy" Angular JS code. The code is about a year or half a year old. I often see stuff like this:
var _link;
_link = "http://localhost";
Or:
var setup,
_link;
_link = "http://localhost";
// ...
setup = {
link: _link
};
return setup;
This looks super verb... |
I currently work for a web design and development company and for the past couple of months I have developed over 10 websites and about 2/3s are live on the web. now most of these websites were for clients who were getting and update to their original website which were already developed by my employer in previous year... |
My input are two polylines -- I had one polyline and I computed offset of it, similarly to polygons. Here is the useful post: https://stackoverflow.com/questions/1109536/an-algorithm-for-inflating-deflating-offsetting-buffering-polygons
So I have to correct polylines, however the number of vertices (and segments) can v... |
In Agile Software Development: Principles, Patterns, and Practices, Uncle Bob talks about client owning the service interface.
My questions are :
Should client always own the interface or only when the client changes less often i.e. at higher level of abstraction than classes which implement the interface?
Is there a... |
I would like to learn how to make graphs and perform some local operations on them in Haskell, but the question is not specific to Haskell, and instead of graphs we may consider doubly linked lists.
Question: What would be an idiomatic or recommended way to implement a doubly linked list (or other doubly linked or circ... |
Several servers I have dealt with will return HTTP 200 for requests that the client ought to consider a failure, with something like 'success : false' in the body.
This does not seem like a proper implementation of HTTP codes to me, particularly in cases of failed authentication. I have read HTTP error codes pretty suc... |
I've been doing some testing in an app that I've been involved with for the past little while, and it appears as though some of the code we've written is causing a race condition.
What's happening is something like this:
//We make this call which resolves a task in a BPM service
//causing a process instance to flow to ... |
Setup
(schema simplified for clarity)
Suppose I have a table called resource:
+---------------+--------------+------+-----+
| Field | Type | Null | Key |
+---------------+--------------+------+-----+
| id | int(11) | NO | PRI |
| name | varchar(255) | NO | |
| owner_id ... |
Here let me take a simple parking boy example.
A parking boy can manage several parking lots, and when a car comes, he will park the car into some parking lot and can also help to un-park the car.
So basically in my mind, there will be a ParkingBoy class like this:
class ParkingBoy {
public ParkingBoy(List<Parking... |
This is common in games, specially management games like Sim City, Civilization, etc: you have actions which provide additional integer bonuses to a metric, but the metric itself remains in a finite scale.
So, for example, suppose you have an Environment metric that's on a 0-10 scale. You can buy an item that adds +2 t... |
Often DIP is known as the Hollywood principle: "Don't call us, we'll call you.".
But doesn't always higher level module calls lower level module, whether there is dependency inversion or not?
Then why is DIP called the Hollywood principle?
Am I missing something? Thanks!
|
What we are trying to do:
We're trying to build a system that will count the number of unique entries for a certain timeframe. It's working ok until the data grows up or the timeframe increase, then we get some OOM Exception or the response it's just too slow.
To simplify it's more or less the classic word-count but wi... |
Let's assume I have a class that downloads data from API, cleans it and saves to database. What methods should I expose?
class ApiConnector1
{
public string GetDataFromApi()
{
// ...
}
/// <summary>
/// removes unnecessary records
/// </summary>
public string CleanApiData(string api... |
We're looking into agile increasingly at my company but I think it works better for some projects than others.
We have one product that is all ours and we control the roadmap. This is obviously perfect for agile.
However, a lot of our work involves putting in a proposal or bid against other vendors for custom developme... |
So I have a factory which creates objects of different classes.
The possible classes are all derived from an abstract ancestor.
The factory has a configuration file (JSON syntax) and decides which class to create, depending on the user's configuration.
To achieve this, the factory uses boost::property_tree for JSON-par... |
I'm creating a work diary web application in mvc using vb.net The application will display any diary entries that have a HiLite boolean field (HL) set to true in a table on the home page.
Currently I've implemented a simple refresh of the home page using a meta tag that refreshes the page every 2 mins and this copes wi... |
In a discussion about domain driven design I have learned the different people seem to think of different things when using the word aggregate. The main difficulty is that some people use the word aggregate for what other people call aggregate type.
It is quite difficult to have a discussion if people assume different ... |
I'm really interested in writing my own converter.
I know C++/Python/Objective-C/Swift and a little Haskell.
There are website like objectivec2swift and iswift.org, which can convert OC to Swift online.
I have a strong interest in making my own parser and compiler, but I don't know what should I do to get start with th... |
The anemic domain model is described as an anti-pattern in domain driven design by Martin Fowler. To have business logic on the domain models often domain services are used. But injecting domain services into domain models is considered harmful by Vaughn Vernon (see "Implementing Domain-Driven Design, Page 387).
In my ... |
After reading the answers to this question, and this and this related questions, I'm now confused about how/if to work with an enum having an NxN relationship.
Let's say I have an entity Hotel, an my hotels can offer some services: sauna, gym, wifi, etc. Following
You should decide whether your Platform is an entity o... |
Got an organization that its core work is acquiring various sources of data, validating it and integrating it to existing mostly financial data sets and then availing that data to many different types of customers through various web, mobile, USSD and API applications it has developed internally and others which have b... |
I am working on an AngularJS project and the attributes are numerous in many of my HTML elements:
<button type="submit"
ng-click="Page.UI.DetailView.ExecuteFunction()"
ng-disabled="step5.$invalid"
class="btn btn-success pull-right">
Submit this Product
</button>
Is there a st... |
At my current position, it's common for teams to completely switch projects and hand-off their tasks to another team even if there is no valid reason, such as the other team having more experience with the project.
The argument to this is that it keeps teams well aware of the entire ecosystem and adds redundancy. For i... |
Why does an inner class sometimes have to explicitly specify the outer class instance in order to call an outer class method for which there is no matching method in the inner class?
Example:
import java.util.Iterator;
public class Outer {
void remove(int index) {}
private class Inner implements Iterator {
... |
The MSDN page on ByRef and ByVal keywords isn't very helpful; unless I somehow skipped it, they're simply being referred to as "keywords" everywhere.
One of the main contributors of the Rubberduck project is working on a very cool Encapsulate Field refactoring, and the UI is coming along pretty nicely.. except I have a... |
I am working on a database interface to a MongoDB using Python Eve as an API.
The database stores several documents containing parameters and values needed for some calculations. I wrote a Python module containing all the calculation routines which need to have access to the desired data.
Since the calculations need so... |
The following is snippet of an example from page 240 of the book Programming Scala (Wampler & Payne, 2009; O'Reilly Media):
/** @return Parser[Money] */
def deductItem = deductKind ~> deductAmount
Is there any reason to do this instead of just specifying the return type with an actual type annotation, as below?
def de... |
I'm in the planning stages of a web application that makes heavy use of data retrieved from a third party's REST API. This data is cached on the server and requested by clients via AJAX. The REST API has a rate limit, and I plan on using the token bucket scheme to adhere to it. However, I'm having trouble coming up wit... |
I'm thinking about a database schema, and would really appreciate if some of you could look at where I'm up to and offer some advice..
The mission - We have to write a program that will fetch data from around 50 different APIs from local governments providing event information. These APIs are not standardized, so schem... |
I am working to create a C# library that wraps a C DLL to integrate with our test system. The C DLL has probably close to 100 functions that can be accessed and all from the same DLL. I don't need all functions wrapped at this time, but I want to ensure I am setup in a direction that makes implementing everything main... |
In our company we have a handful of R users who have collectively written some ~30 .R scripts over the last year. The scripts are mostly 100 lines or less, defining useful and reusable functions.
Currently everyone's .Rprofile contains some code that sources all of the files in a shared 'Common R Scripts' directory on... |
I need to develop an API, the functions of the API are requests that call the service exposed by a server.
Initially the API worked like this:
class Server:
def firstRequest(self, arg1, arg2):
# block of code A
async = Async()
async.callFirstRequest(arg1, arg2)
# block of code B
... |
Years ago AFAIK the mathematitician and software developer Tim Peters discovered that very often the documentation of APIs tends to get out of date over time during the software live cycle, because the comments documenting the API are often overlooked when features are added or the call signatures of functions or metho... |
Sometimes the user starts an extended technical operation that takes a while to execute. In these cases, it's usually nice to display some kind of progress bar, along with information about which task is being executed right now.
In order to avoid close-coupling the UI and the logic layers, it's usually best to have t... |
I'm working on a port from Python to Rust and ran into some code that can't be expressed as naturally in Rust as they can in Python.
One case of this is using default parameters:
class Foo:
def __init__(self, a="Hello"):
self._a = a
In Rust, you might implement this using a builder:
struct FooBuilder {
a: &'st... |
We're figuring out whether we should write acceptance tests that revolves around preloaded data on a database file, or programmatically added needed data per test, or filling database while testing other application features.
This is a more detailed, easy use case: you want to acceptance test (or UI-test) adding a Book... |
I'm currently in the process of setting up roles where there are regular users, admins, and super admins, each of which have special permissions. I deferred to this post on how to do so.
It basically comes down to either setting up a few tables in addition to the User table: Roles (second table), UserRoles (join table... |
Well basically, I have an Engine class that recieves a command as string from the input and passes it to a CommandHandler class which executes the apropriate command.
The CommandHandler passes the string to a CommandFactory to get the command and calls the method Execute() of the command, but the problem is that every ... |
I was trying to solve this problem on hackerearth where you have a tree with values on each node and you have to answer queries that ask what is the xor sum between two nodes. Also, there are updates that you have to make(the value of a node can change). I solved the easy part (dfs and lca) and for each node I saved th... |
I am working on a design, but keep hitting a roadblock. I have a particular class (ModelDef) that is essentially the owner of a complex node tree built by parsing an XML schema (think DOM). I want to follow good design principles (SOLID), and ensure that the resulting system is easily testable. I have every intention o... |
First of all, let me apologize because I know my question will be very confusing since my English is pretty bad.
I am working on a project for a company, mainly create a system to take care for their good, using MVVM C#
My MS SQL database looks like this
So I have auto-increment for both Bike-id and Contact-id. Each ... |
In the past few days I've been reading some things about microservices architecture. I didn't get the whole point yet, since I'm just starting with this, but there's one point which caught my attention. In some sense it seems to me that microservices are a concrete way to leverage the idea of Bounded Contexts from DDD.... |
I know this is a very broad, ambiguous, and possibly philosophical question. To an extent, that the most important keyword in the question - "strong" type system - itself, is ill-defined. So, let me try to explain what I mean.
Overall context for the question
We've been building a very large scale web-app in Ruby on Ra... |
For most applications, when you type a key on your keyboard it often prints onto screen the letter corresponding to the keystroke.
By "printing" I mean the set of pixels associated with the keystroke gets displayed on-screen.
How does your computer translate the keyboard input into the pixels you see on the screen?
|
Is the "Builder" pattern restricted to addressing the "telescoping constructor" anti-pattern, or can it be said to also address the more general problem of complicated creation of immutable objects?
The StringBuilder class has the word "builder" in its name, but it has nothing to do with telescoping constructors, it si... |
We have a legacy ASP.Net application (written in c# a few years ago) which allows a factory manufacture a number of custom-made products. Different attributes such as color, length, width, etc. are common for all product types, but each product type carries a set of attributes specific to type. The application currentl... |
I am looking for a way to design a ddd application with convention over configuration.
Say an aggregate "Client" has a command defined "FillProfile". It will logically raise an event "ProfileFilled".
Are there cases when a command will raise more than an event, or where a command will raise different events based on s... |
Let's say I have a class that needs some helper methods to do its work. The number of helper methods starts to grow and the size of the class also starts to grow a lot.
How should I handle this problem?
Should I generalize the methods and create a static Helper class even though I know that, for now, only one class ne... |
I like domain driven design, and onion design. However I would really like my features to be encapsulated. If i check out some legacy code and I need to investigate some specific feature the best thing that I think could happen to me is that I see (lets say in java) is that there would be a package with featurename a... |
Talking generic, there are programming languages who make more or less use of annotations and decorators.
Be it to add type information to variables in a dynamically typed language or to add "metadata" to methods and classes in a framework context. The "purpose" of them is always to in some way extend the language in ... |
I've heard it said that you should keep query and modifier functions separate from one another, and I agree with the sentiment. When trying to apply it, I often run into two issues/questions:
What, if anything, should a modifier return? Should it not return an indicator of success/failure? Should it instead return not... |
The short question is: is it true that for Observer Pattern to work, there probably is some polling mechanism underneath? (update: in a network situation)
It was quite amazing that if on my Macbook Pro, I save a file Hello World.txt into the Dropbox folder, then I actually see it appearing on my other Macbook within 1 ... |
Let's say I have a custom decorator, and I want it to properly handle docstring of decorated function. Problem is: my decorator adds an argument.
from functools import wraps
def custom_decorator(f):
@wraps(f)
def wrapper(arg, need_to_do_more):
'''
:param need_to_do_more: if True: do more
... |
I was wondering what the purpose of separating the instantiation logic and the data loading logic of a class that loads data into memory if the class is a one time use.
Here is an example of what I mean.
DataLoader loader = new DataLoader("serverName", "databaseName");
loader.LoadData();
//Do Something with the loader... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.