instruction stringlengths 34 36.1k |
|---|
Definition of the lazy loading pattern from Wikipedia:
Lazy loading is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed. It can contribute to efficiency in the program's operation if properly and appropriately used. The opposite of lazy l... |
My team currently has a WPF application that runs on PC just fine. It utilizes Entity Framework 6 with the Repository/Unit of Work pattern that talks to Azure for the database store.
We service a little over 300 clients currently. But, we're wanting to expand our footprint for the app and transition to mobile devices.... |
Say, I have an agent whose state includes position and facing_direction. I need to check whether it can move in any direction or is completely stuck (due to various obstacles). Agents have a method can_move() that checks if the agent can move forward, i.e., along its facing_direction.
I can modify the agent's facing_di... |
I have been tasked with helping our HR department create some new interview questions for candidates applying for development positions. As part of the process, I would like to assess their ability to both understand code without the help of a compiler and spot potential future problems.
As such, I have devised a basi... |
Is a total, impure function considered to be Referentially Transparent (RT)?
Example:
// Given an 'id', try to retrieve an optional Person
// from the database, i.e. side-effect.
// Note that 'String' is a poor choice for the `Left`,
// but it's not important for this question
def getPerson(id: Long): Either[String, Op... |
I have below constructor, where it creates a workbook in constructor. I read that, ideally, we should not create objects in Constructor, instead, we should have just assignments which are passed.
public ExcelWriter() {
workbook = new HSSFWorkbook();
//other code
}
Is it okay to create fixed object... |
The .NET CLS (Common Language Specification) allows a programmer to write code in one .NET language and confidently know that all other .NET languages can safely interact with and even utilize data and methods from the original project.
In Troelsen and Japikse's, C# 6.0 and the .NET 4.6 Framework, the authors write tha... |
I would like to initialize my variables at the top of my file, to prevent any Undefined variable notices. But what do you guys think is considered to be best practice (in PHP), in case of a string type variable?
Initialize the variable with a value false by default?
$variable = false;
Or perhaps just an empty string
... |
Is there a name that is commonly used for functions that are only called in one other function?
(I'm not asking whether it's a good practice; I believe it can improve readability in some cases.)
Right now I'm commenting them as "local shorthand functions", but I'd like a more standardized name, if available.
Example:
... |
I am in a situation I cannot decide which approach is the most optimal (performance wise) while being maintainable at the same time (in the sense of having a clear logic).
The question is laid in the context of a Django web app, but I figure it applies to any related scenario.
In my scenario we are visiting a particula... |
I've been teaching myself Object Oriented Programming(Ruby) for a while. However, I still don't quite understand some of its core principles, specifically, instance variable. Could somebody please explain to me why do we need instance variable? What is the problem that it is trying to solve in object oriented programmi... |
From my experience I think that having classes/models without behaviour only in my application, next to their repositories is not good OOP. But, this was the way I implemented the repository pattern. I just make everywhere I need an repository instance, to perform some actions. The result of this approach was that all ... |
In our company I started to develop an ADDIN for a drawing application. The first results of this ADDIN were reviewed as successful by the direction and they want to increase the workload on the application. So they assigned 1 colleague (and possibly 1 more in the future) to the project. Currently my coworker isn't cod... |
I'm working on a project where requirements are rapidly changing, therefore some functionality is built then rapidly replaced by other functionality. I'd like to remove some functionality from the project to keep it tidy, but also be able to find it reasonably fast at a later date.
My project folder structure is like t... |
I'm having a bit of a philosophical argument with one of my colleagues regarding the "right" way to do unit tests (in this case with PHPUnit). I'm of the opinion that you should write one test method in the unit test per test you want to run.
// Obviously a very contrived example!
class AdderTest extends TestCase
{
... |
I have an existing Java architecture that uses a basic proprietary framework.
I want to start developing new functionalities in a framework, ex Play.
In that way I will not lose existing functionalities, I will replace them slowly and I will probably end up seamlessly with a rewritten application.
Is this wise to do? O... |
I'm basically attaching a listener to an event that's triggered when a controller action completes. Said listener has a dependency that calls a 3rd party API client and do some action. I.e: creates a new document in google drive).
Following the example, if the user hasn't authorized through OAuth2, the system should re... |
Since Git is licensed under GPLv2, and, to my understanding, GitHub interacts with Git, shouldn't the whole GitHub codebase be open-sourced in a GPL-compatible license?
|
I want to consume the Tumblr API in C#. Every request to the API returns a JSON-encoded object with the same general outline:
{
"meta": {
"status": 200,
"msg": "OK"
},
"response": { ... }
}
meta is always the same but response is specific to each request.
I would like to have all my methods... |
I'd like to ask for some help in understanding how event-sourcing systems are used when it comes to web applications and POST requests. I understand how events are stored and the event-driven architecture of eventual consistency. I understand CQRS etc, but I cannot imagine how an event store mechanism handles something... |
Usecase: End user places an order on the company website, the order needs to be pushed to company admin's screen with small latency.The company has multiple branches(identified by compId and branchId combination) so the order must be pushed to correct admin.
What I have so far: A REST API that takes Order, persists it ... |
I have a complex system which I have done a pretty good job at separating concerns with microservices. All data is passed around through queues, and the result of the system are messages to update a database model owned by a single agent. I don't have any shared code among the agents of the system.
The problem I am... |
I wonder whether a method in a functional programming language should receive all variables from the argument list, or whether it is ok to use variables from the outer scope?
But let me explain the context firts: The enviroment where I'm working is focused on programming (or better: scripting) Scala in the Scala-REPL /... |
I have read about connected model and disconnected model in the main ORM of Microsoft EF . And found that the default behavior is the disconnected .
Then i read about the relationship between these two models and the software architecture .
1-tier vs. N-tier
1-tier applications like WPF use connected model.
N-tier ap... |
For ex: Two machines have the same compiler and the same operating system. But the two machines have different processors (different assembly instructions).As the compiler was downloaded with respect to the operating system, how does the source code get converted to machine language of each processor?
|
I'm a software developer, and the kind of developer we call "front end developer". I'm working on stuff like Angular, React, Vuejs and many others.
I wanted to know how we can organize our front end code so that we can fit a microservice architecture.
Actually, we scale services across units, each service is "independe... |
Say you are creating some module or service, which is responsible for creating certain ratings, i.e. you're creating a rating service for e-books and you are trying to judge how romantic a book is. And for that service you create some test, where you use real books, which you have read and know how you would rate them ... |
I am developing a Human Activity Recognition android application. Currently, I am at the Design stage where I am designing the architecture of the app. I am using the MVP architecture pattern. I have to note that I am learning how to develop a software architecture while thinking about the design of my app so please ta... |
I am trying to decouple a dependency from Book Class to BookStorage, but got confused how to do this right. Can someone tell me how to decouple this correctly? Here is my code:
public interface IBook
{
string Execute(Guid bookId);
}
public class Book : IBook
{
public string Execute(... |
Recently I've tested the limit of a stack on three devices with different OSs (by limit, I mean the maximum number of levels that can the stack have), and I noticed that every time when I hit 2^16 levels it gives me overflow error, and when I put 2^16-1 it works properly.
So my question is - is that true? Does the stac... |
This had probably started way back when Microsoft created ASP.NET Web API library, at least that's when I remember it if I am not mistaken. Anyway, since then, its HTTP packages started depending on Newtonsoft.Json library for data (de)serialization to and from JSON.
Why would a company as large as Microsoft would add ... |
We have a web api c# project that was build using database-first several years ago. Now there is a need to make a transition to DDD architecture for this same project. The main reason for this is to put emphasis on business logic (that did not change a lot) and application design so it has a room to expand with new fun... |
I'm building a Spring-Boot API that will serve a system that requires synchronous behavior despite the API doing async operations. I'm not too familiar with threads and I'm thinking this might be the right place to use them. I'm eager to hear some input.
Here are the restraints:
1. API will write to queue when reques... |
Building an android app that displays a list of of Dog objects in Activity A. When you a tap a Dog in the list, that single dog is accessed by Activity B, Fragment B, and 3 other classes.
After that Dog is modified, it gets passed to Activity C and Activity D that all modify it, before finally making a network request... |
A page I'm working on has seemingly random anchor tags showing up all over the place, which is causing significant formatting issues. Those tags are showing up in Chrome DevTools but not the page source, which suggests that they were added via jQuery.
How can I track down where those mysterious tags are coming from? Th... |
I was reading Death of for-loop article, and I thought maybe I should timeit the codes. I created this benchmark at jsperf which clearly shows that map-filter approach is about 90% slower.
So, why is FP code here is slower? and also, why be functional if it is slower?
The author was only talking about readability when ... |
Introduction:
I've been a procedural PHP programmer. For a few months I've been following OO tutorials and watched a lot of videos on this subject. It's 100% clear that the OO method is way more efficient programming, especially because my project sizes are growing.
So what i want learn the way of object oriented think... |
I am writing a wrapper for a REST API and I have run into something I have never had to ask myself before.
This API is for E-Commerce transactions, it has SALE and RETURN endpoints (and some other endpoints that aren't critical to this discussion).
The SALE and RETURN requests are nearly identical, with the exception t... |
I am working on a large project in python that has lots of imports.
Some imports are system imports - these are easy, usually just absolutely imported.
Some imports are third-party. These can have long, clunky absolute names, but clearly named single functions (requiring from ... import statements). Finally, some have... |
Say I have a computer vision system capable of tracking multiple colored blobs. Further, assume I want the blobs to represent "fingers" in a multitouch system. Now, I have many examples I can look at to see how to make multitouch gestures. However, I cannot seem to find a clear explanation of how a "touch" event is def... |
So let's say you're writing software for some company. Best practices, as I understand them, would dictate that for dev purposes, you populate your DB with fake data. There are a number of benefits to this.
If you're going to be using, say, Vagrant to manage your dev environment, most of the pre-built images have HDD'... |
When several persons work together on a project shared in repositories in github, it happens quite often that I feel that someone else's code is hard to read, and want to change and reorganize his code and add more comments.
It is for improving readability just for my own purpose, and I don't want to ask others to ch... |
Say... you're trying to write a networkCallback code in java:
public interface NetworkCallback {
void onNetworkResult1(Object object);
void onNetworkFailure(Object object);
}
you want to use it, but you sometimes have two network results:
public interface NetworkCallback2 implements NetworkCallback {
void ... |
At the moment of writing I have let's say 4 micro services interoperating in order to build a bigger system.
Every microservice has its own repo.
What I'm thinking is that it would be useful to have parent repositories that group the children microservices, adding them as git submodules.
So if a developer needs to wor... |
Situation:
There's a remote team of 6 developers in 4 different countries. It uses CI, version control, Slack and has a weekly status call. They do code reviews on each pull request (always same reviewer). However there are no formal rules on code organization, style and layout. Some of the team members work part-time,... |
We have two modules: D and S. S has a Web Service interface, which is being used by D.
S's responsibility is managing a domain of objects held in a folder-like structure. So, it contains a method like: object Get(Path path), where Path DTO represents a collection of strings, which are components of a path (i.e. to get ... |
SITUATION
Let's assume we want to generate an excel report with the data from microservice A and present it in microservice B. We can obtain the data with some scheduled task or so.
POSSIBLE SOLUTIONS
Simplest
We add a report functionality to microservice B and generate reports there.
Pros:
Pretty strightforward, on ... |
I am trying to design a RESTful (or maybe I should say RESTlike, since I am not designing a fully RESTful API, e.g. not hypertext driven) API as part of a refactoring of an existing "take-a-number" queuing management system.
The basic concepts and workflow are :
A given site (location) can propose several different se... |
This is really just a theoretical question by a python newbie who wants to understand more.
I keep forgetting the colon after the block initial statements in python. Those are what I mean:
for <variable> in <sequence>:
if <blah blah>:
My thought is that one reason I keep forgeting is, that they are de-facto implicit:... |
I've just joined a new company that has recently switched development from PHP to C#/.Net Core. They're writing a new CMS from the ground up in this new environment.
Before me, there was only one developer working on this new system, and he set up a system that is rather hard to work with. I'm trying to think of ways t... |
I have many client applications that sync up to a central server.
I am using C#, MS SQL server, Win Forms, ASP.NET MVC + API.
I need to learn/figure out how to perform a 2 way sync for data changes across my server database and local databases.
My server and local databases are almost (but not quite) an exact match.
Th... |
Lets say we have a backend server maybe a database or whatever. When generating the use cases for that server who would be considered as the actor? System(front-end) or the user(user interacts only via the front-end with our server) ?
|
I have recently mastered the Lambda expression that was introduced in java 8. I find that whenever I am using a functional interface, I tend to always use a Lambda expression instead of creating a class that implements the functional interface.
Is this considered good practice? Or are their situations where using a Lam... |
Thinking about statelessness I wonder how I can overcome the issue of saving the user's password on the client side in a secure but also comfy way.
I assume the client always sends credentials to the server and that uses CPU power to verify the authenticity and also make sure the user has the authorization to do whatev... |
I am looking to an IoT like system which must deal with a wide range of data complexities. As an example, I'd like to model a 'thing' and I know all things have a location. However, when the actual data arrives from these things (from different vendors), something like latitude can be spelled, it may have different n... |
I have used data-driven design in the past and it has worked quite well. What I dislike about it is if you need some form of a string whose value has to be updated based on other values.
e.g., "Exports %x percent of %y". In that case you will need an extra column serving as an identifier, to tell which variable in your... |
I have a limited amount of input types:
34:56 = sensorA#, sensorA#, sensorB#
2:5 = { led# }
66 = otherSensor
2,3,4,5 = greenRelay#, redRelay#, relayA#, relayA#
a:b implies range.
{name} implies a global name for the dataset.
# represents automatic enumeration in the name (not relevant for the
question)
Single v... |
This question is about finding approaches to solve a specific problem.
I have a table which has several metrics with values.
[metric1] [metric2] [metric3] [metric...N]
Those columns are fixed.
I need the user to be able to generate calculated metrics using the existing columns.
Let's say that a user made a custom metr... |
I have a 2500 line Character class that:
Tracks the internal state of the character in the game.
Loads and persists that state.
Handles ~30 incoming commands (usually = forwards them to the Game, but some read-only commands are responded to immediately).
Receives ~80 calls from Game regarding actions it is takes and r... |
I have an object Carconstructed using builder pattern.
Issue was a lot of code redundancy.
Car.Builder builder = new Car.Builder("Mercedes");
builder.numDoors(carConfig.getNumDoors()
builder.engineType(carConfig.getEngineType())
builder.isManual(isManual)
builder.build())
Car.Builder builder = ... |
In software development we usually do a analysis phase where requirements are taken, user interfaces are designed (for software with ui), etc. After the analysis phase you know what to do, and you can estimate (aprox.) the effort and the cost for the future tasks. But usually I noticed in some companies, the analysis p... |
I think I understand what Promises are about, and I think I understand what continuations are about, but I still fail to see what their connection is.
In what ways do Promises use Continuations. They never return, which is explained by the fact that they use Continuations, but I don't see when and why they do the "jump... |
I just wrote a function and I'm not sure if it is a good idea.
The motivation is, I'd like to store some internal bookkeeping data along with my business data in one big happy javascript object. When that object is consumed, I would like to strip the internal variables. As a convention, my internal variables take t... |
what does it mean when some technical guy asks did you work on cloud ?
I have worked primarily java based web applications. But sometime in discussion/interviews technical folks asks Have you worked on cloud . To me cloud looks very broad term and I can think of below three related work related to cloud
1. work on we... |
GO has embraced,
1)
JavaScript/Python language constructs,
Higher order function
Closure
Slicing
Range operator
Anonymous function(inner function)
Provides abstractions for map object
for..in as for..range
2)
C language constructs,
Non reference type('var a int')
Variadic functions
Overriding init() function
struct ... |
If I make a class, that in the constructor accepts an array or collection, but this array or collection is optional (the parameter can be null), and then I store that collection in the object in question, in the constructor i need something like:
this.coll = coll == null ? null : coll.clone();
Should I unit-test such ... |
What is the best course of action in TDD if, after implementing the logic correctly, the test still fails (because there is a mistake in the test)?
For example, suppose you would like to develop the following function:
int add(int a, int b) {
return a + b;
}
Suppose we develop it in the following steps:
Write tes... |
For simplicity's sake, let's say I'm maintaining a fork of Bootstrap. My changes are specific to my theme, so they'll never be merged back into the original Bootstrap project, but I still want to make sure that my project has the latest changes. Over the life of the project, I'll merge in Bootstrap's changes several ti... |
I was reading the RFC 2616 regarding HTTP/1.1 when this term came up:
Therefore, the HTTP/1.1 protocol provides these important elements: [...] Protocol features that provide full semantic transparency when this is required by all parties.
[...]
The Cache-Control header allows a client or server to transmit a
v... |
I'm developing an app (for Android) which uses data received from my rest services. These services use also GPL libraries: if I have correctly understood, if a server side web application uses GPL libraries it has not requirements to release its source code as GPL. Has my app code any requirements if it uses this rest ... |
C is a static-typed language that is not type-safe, because pointers(void *y) let you do pretty much anything you like, even things that will crash your program.
GO is also a static typed language
Despite, GO has pointers(var y *int), it is still considered type-safe language.
Question:
Considering GO pointers,
Why GO... |
So I am working on a legacy system, that had one database server. For reporting and to split the work load it has been moved to a Master / Slave setup. This process is done and seems to be working well with little to no lag between an insert or update on the master, and it being copied to the slave. The problem I have ... |
Imagine I have to manage products.
Products have features , features maybe have free input option, or set of limited options,
not all the probabilities will be available:
options01/features01 * options02/features02 * ... options0n/features0n
so I have a set of rules where on
specific condition on a feature:
black... |
Virtualenv appends its own path to $PATH, effectively overwriting the Python to the one picked when the virtualenv is created. Would changing the $PATH work equivalently as virtualenv in a compiled language with shared libs?
I am asking this because it seems that there is no easy replacement of virtualenv for e.g. C (w... |
I am creating some software that runs on a machine that performs multiple tests on a product that is built at my company. I am also trying to improve my coding and I have been recently researching design patterns and seeing how I can apply them to my code.
The part I am currently looking at is the actual test sequence.... |
Here's a small illustration of my question:
Assume a build job that consists of 4 independent tasks named A-D. D takes longer than A-C do in sum.
A build system that cannot incorporate the relative task times might schedule the tasks like this:
---------------------------------------
CPU1: A | C |
---------------... |
I just realized that in Python, if one writes
for i in a:
i += 1
The elements of the original list a will actually not be affect at all, since the variable i turns out to just be a copy of the original element in a.
In order to modify the original element,
for index, i in enumerate(a):
a[index] += 1
would b... |
At work I'm using Java, but I'm planning to study some other programming languages as Python or Clojure.
I'm thinking of coding one project in Java in my Git repository and, during my study, coding the same functionality in Python or Clojure.
Because it will be a project without an effective value at work and by a pers... |
I ran into an issue where I forgot to resolve my promise, leaving the remainder of the chain waiting (Forever). Thankfully in my case I was able to track down the issue in only 10 or so minutes, but I could see this being a really big pain in the butt if I don't figure out some way to check for orphaned promise chain... |
I am currently learning about various object oriented design patterns. I came across a pattern called the builder pattern which is basically where you build a complex object through the use of creating simple objects that build on each other step by step.
My question is, in what scenarios would such a design pattern be... |
Working in an architecture roles I was asking the team that was developing a component to add some logging at certain points. For this I was offered and NFR document to fill in.
Does logging fit as a Non functional Requirement or could they go somewhere else. in oneway a NFR document is convienent for a boiler plate r... |
I made a simple algorithm that makes my logs more suitable to be plotted. A logfile has the following structure:
timestamp bytes
and looks like this:
1485762953167032 517
1485762953167657 517
1485762953188416 517
1485762953188504 517
1485762953195641 151
1485762953196256 151
1485762953198736 216
1485762953200099 216
1... |
I am required to write tests for an API at work to make sure we don't break it as we develop on it. So far, the solutions that cam out are as follow :
"prod" code and "devel" code running on the same DB (with a dump of the production database);
"prod" code and "devel" code running on their own DB.
Both solutions requ... |
my question is related with Angular 2 Modules (@NgModule).
Previously I’ve worked with angular 1.5.8 on huge business application and I’ve got used to Angular 1.x practices.
Important background:
Right now I'm developing something more then single application. It's going to be more like business platform. We set up com... |
In scrum how do you handle sizing things accurately without overcommiting and still keeping the team honest?
In my agile team I am seeing us size things large with some buffer, usually 2 or 3 points larger with typical ticket sizes 5 and under, to account for mistakes in the sizing so we don't overcommit in our sprints... |
I'm working with particular classes of matrices which admit fast operations without resorting to dense linear algebra. To keep the heierarchy simple, I'm currently doing the following (greatly simplified):
class Matrix:
def mvm() # matrix-vector multiplication
def is_square()
def is_psd()
def is_symm()
... |
I'm working into a project that needs to implement a Reverse Socks5 connection.
In practical terms, the browser (Chrome/FireFox/Opera/IE) will connect on a local socks server (127.0.0.1:8080), and on this same server I will have a remote client connection on another port (192.168.0.9:8081).
Once I open a website on the... |
In GO, rule is, methods can be defined only on named type and pointer to named type.
In C, below code, operations are defined on type(say List),
typedef struct List List; //list.h
typedef struct {
bool(*canHandle)(ImplType);
List*(*createList)();
....
const void*(*listGetItem)(List*... |
I'm currently working on an architecture that have the following structure:
(central server)
/ | \
(local server) (local server) (local server)
/ | | | | \
(PC) ... (PC) (P... |
I and three other people got some money to build an educational mobile app (sociology for high school students). The software requirements are decided largely by ourselves. The team will consist of the following people: two experts, one whose role is to create the teaching material (questions, text, etc) and one who wi... |
I am using software in my code that is distributed as BSD license. It has a lincense.txt which describes the original authors who wrote that software. It asks me to retain the txt file, etc when i publish my code which i will do. But do i also have to cite it when i publish a paper? The license doesn't say anything abo... |
I'm creating an application that allows you to input Orders, an order has some basic information: who ordered it, what date, etc. It also has a list of line items that are ordered. Each line item can (probably 50% of the time) have it's own delivery date separate from each of the other line items, they can also be star... |
I want to preface this question by apologizing for its length, especially the code samples; however, I believe I have included the minimum necessary code to illustrate the differences in approaches.
I have a class with a number of instance attributes, and each of these attributes has some respective attributes.
For ex... |
Background:
pthreads follow pre-emptive scheduling, whereas C++ fibers follow cooperative scheduling.
With Pthreads: the current execution path may be interrupted or preempted at any time This means that for threads, data integrity is a big issue because one thread may be stopped in the middle of updating a chunk of d... |
I'm developing a framework with C++, and it contains three layers:
Low level functions which do the hard work
An upper layer which uses the low level functions to accomplish tasks (functions at this level generally uses only one lower level function and explicitly accepts the pointer of the function to know which func... |
Says, I have employee table, with {id, name, unit, etc..} what is the preferred ways to get this data if I frequently use this data, my first option is to query it from database when needed, something like this,
public static List<Employee> GetEmployees(string unitID)
{
List<Employee> employees = new List<Employee>... |
I'm currently working on a n-tier web application using ASP.NET Web API 2.
It has been decided to use boilerplate as DI framework.
Now, I need to reconsider the architecture that ties the business layer to the persistence layer.
The current architecture is making use of a Persistence Facade that exposes the writing/... |
I know that, on github, you can define a protected branch and allow only certain users to merge a pull request there.
Say, for instance, that users A, B, C and D are developers and A is team leader and the one that should be responsible for merging the pull requests into the protected development branch. It happens tha... |
Scenario:
we want test drive a create method, the resulting method would look like this:
public MyModel Create(MyModel model){
var dao = TransformToDao(model);
dao.Date = DateTime.Now;
var result = _repository.Create(dao);
return TranformToModel(result);
}
I think two test points for this method should... |
I have a war file of a web application which I want to deploy in production mode. I am confused as to how I should go about it. I was currently working Apache Tomcat to develop and debug the application. Will tomcat be suitable for a production release as well if I'm expecting heavy traffic on the web application? If n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.