instruction stringlengths 34 36.1k |
|---|
Should we avoid multiple interface if possible? Because I think at most cases a class with multiple interfaces can be replaced with another version with composition and single interface only e.g.:
multiple interface:
public class C implements A,B{
@Override
public void a(){
}
public void b(){
}
}
c... |
public class Factory
{
public INode CreateNode(TypeEnum type)
{
switch(type)
{
case TypeEnum.Document:
return new DocumentNode(this);
case TypeEnum.Item:
return new ItemNode();
}
}
}
public interface INode
{
void DoAction();
}
publ... |
I've recently been shown some JavaScript plugins written for OBIEE Mobile App Developer, as well as some custom libraries for various projects.
Coming from an OOP background, I am a little confused about the structure of these projects. I am seeing files that are thousands of lines long. I am used to splitting things i... |
Prefixing methods and members with an underscore indicates internal use. For simple classes, I sometimes find the easier reading and typing of self.foo outweighing the indent of self._foo. Especially when implementing an abstract interface, this interface is already pretty clear. Of course, the class could have more pu... |
Considering that Spring framework can manage pretty everything related to object creation (life cycle, object scope ..), is it longer necessary to use singleton pattern in an application using the framework, or are there still situations when we need to use Singleton pattern instead of singleton instance created by Spr... |
MVC is pretty straightforward. There is a Model, a Controller and a View. When we create a website, it all come together as 'client sends REST keyword request to server -> the server matches the requested URL to the controller action -> which then calls the model(s) for data gathering/processing, gets the result -> and... |
In a JavaScript app, suppose I have a nested object like this:
var myObject = {
someProp: {
someOtherProp: {
anotherOne: {
yetAnother: {
myValue: "hello!"
}
}
}
}
}
In another part of the code, I'm calling myValue multi... |
Google API key is now required for new websites even for a single map embed.
How are you going to handle this?
I guess the correct way should be to ask a client to create his google API key and send it to you.
The first problem is that not all my client has a google account, some doesn't have one and some have a person... |
I'm trying to find a way to avoid starvation in my program, a producer/consumer (two threads, one for each role) problem with four priority levels (four deques).
Basically, the consumer thread always remove from the max priority deque until nothing is left, than it goes to remove to the medium priority deque, and so on... |
This is a academic question, but I think only professional programmers are the people who can answer this.
Is it true that whatever we can do with pointers, we can do without them as well?
This is something one of my undergrad teachers mentioned and I never really cared to find out, now it seems I have to. I and anot... |
tl;dr - On an existing angularjs grid library, am moving to another.
Is it better to wipe out as much code as possible and in a sense code from scratch to the same featureset, or work around what's there?
Is there a recommended way (or even a good idea) to try to leverage what's there?
Better context:
My team has inhe... |
I am developing a project in C++ that deals with converting an ASCII hexadecimal string representation into binary. The class also has utilities in it for extracting info from the string.
Right now my project contains ASCIIUtil.hpp/cpp and Parser.hpp/cpp and it seems to be working correctly. However, I feel like a cla... |
The Scenario
I have a Classic ASP project with a SQL Server backend that I need to port to ASP.NET MVC.
The legacy site makes liberal use of schema definition analysis in the application itself. For example, to run a given report and let the user supply a sort order, the application will read the schema and provide a ... |
Silent failure for such trivial code. How can they claim high integrity?
with ada.text_io;
use ada.text_io;
procedure overflow is
procedure p (i: positive) is
x: integer := integer'last;
begin
x := (x+i)/2;
put_line (integer'image(x) & " should be positive");
end;
begin
p(10);
e... |
I am interested in creating a specification for the representation of complex hierarchical (domain-specific) data in a way that is independent of implementation. Think of a blueprint from which you can implement classes (in your language of choice), an xml schema, database tables, a yaml structure, or whatever. The s... |
Let's take a traditional functional requirement:
The system shall allow the user to create an account with an email address and
password
A user story that covers this requirement might be:
As a shopper I want to create an account so that my preferences will be retained
And the acceptance criteria for this story m... |
Design and implement Cash Register:
Given a number of items you will be required to calculate the total bill.
Items are charged for in a couple of different ways:
A given price for each item, e.g. Boxes of Cheerios are $6.99 each
A given price by weight, e.g. Apples are $2.49 per pound
Items can go on sale where you m... |
I read about this snafu: Programming bug costs Citigroup $7m after legit transactions mistaken for test data for 15 years.
When the system was introduced in the mid-1990s, the program code filtered out any transactions that were given three-digit branch codes from 089 to 100 and used those prefixes for testing purpose... |
This might sound similar to some of the other questions but it does not deal with wait or notify.
I have two threads which do two different things
The first forms a process in the background and changes behavior when it receives an input from the other thread that interacts with the user.
|
I'm working on an CRM type application(.NET, SQL Server) that needs to generate reports from large datasets, millions of database rows in a dozen different tables with a lot of aggregation and logic. The reports are currently generated by long, complicated stored procedures with lots of joins, temp tables and logic. ... |
Here are the two cases under consideration. (a)Scalars and (b) Numpy matrices. My query is about initialization and assignment.
1 Perfect
y = x = 0;
x = 7
print(x,y)
y = 8
print(x,y)
x=10
print( x,y)
output is perfectly fine. Effect of y = x = 0 is not seen.
7 0
7 8
10 8
2 Perfect
import numpy as np
n=3
#d11 = ... |
In a regular WSGI service provider implementation there is a blocking HTTP server that services clients. When a client, for example, creates an invoice, the server simply makes a CRUD operation that creates rows in necessary tables. Then there is a worker - typically a shell script that uses the same set of models the ... |
I often have a situation where I first need to do something in the UI thread (Android in this case), then to some networkstuff in an extra thread, switch back to the UI thread and udate the layout, etc.
This looks most of the time like this:
MainActivity.getActivity().runOnUiThread(new Runnable(){
@Override
pu... |
At my new job I am working on a basic existing CRUD web application in MVC + with an Angular front-end.
The MVC API has a Swagger spec and it's used to generate an API client with auto rest. That API client is consumed by the front-end.
Now I understand the technical implementation but I am scratching my on why this is... |
I'm trying to write a simple game and I really want to finally create something that would be "programmatically correct". I stuck with a problem like this: I have class
public abstract class ProjectileLogic<T> where T : ProjectileInfo{
protected T _projectileInfo;
public abstract void OnInitialize();
public... |
We have a conventional application built using ASP.Net Web forms which uses SQL Server for database. Reports are generated using SSRS. We have a main table called ManifestContainerDetails - this table is for reporting purpose. When shipping is done for a manifest, it’s component details will be stored in this table. Th... |
Should a daemon, forked from a CGI script (whenever the CGI script is called and the daemon is not yet running), hang running (most of the time just waiting for a connection) all time, or should it be terminated as soon as there is no more data to process (to be restarted by the next CGI call)? (The process is a Perl s... |
I'm quite unsure what I should use in C# - both should in theory do the same, but I think both are quite easely overseen. Or is there another possibility I have to take in consideration?
I know in C++ you use copy-constructors. But in C# I have never heard much of them (they are just a ctor with self as parameter and s... |
Is there any way that I can remove or add element in map I am currently iterating(using iterator) upon. Please suggest.
|
When auto was considered for addition to the C++ standard, was there any discussion of setting implicit types where there are no explicit declarations? And if so, was the discussion recorded anywhere?
Not intended as a criticism. Just curious from a PL perspective.
|
I'm using some code, which uses variables declared in a loop after the loop. For example
for (int i = 0; i != 10; i++)
{
// do stuff
}
int x = i;
I get the "i" undefined error. Is there a compiler switch to change this (in VC++ 2015)?
|
There is a lot of content on the web discussing if it is worth defining an interface if only one class implements it. The answers are mostly either "Yes, because you probably need to mock it anyways" or "No, I strongly believe in YAGNI".
But what about narrowing the classes public interface?
Example:
public interface P... |
Recently, I've read a blog post, that I can't find back, about how we should "free the data". The main point of the post was that we use classes and encapsulation too much since a lot of problems can be solved with less overhead by using plain old (passive) data structure combined with function overload. The post raise... |
Can I use R via RDOTNET without having to provide the source code of my application.
R is covered under GNU GPLv3.
RDOTNET is under New BSD.
From the RDOTNET description:
"R.NET enables the .NET Framework to interoperate with the R statistical language in the same process. R.NET works on Windows, Linux and MacOS."
I u... |
I'm developing a virtual assistant to manage transactions in a business. I'm using an external service to handle Natural Language and
get intents, actions and parameters from my user requests.
The client sends requests as text strings to my application logic and my application logic routes the messages to the NLP or th... |
Let us consider the following C# code as an example:
public static string GetCurentExecutableDirectory()
{
return System.IO.Path.GetFullPath(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
}
According to documentation, System.Reflection.Assembly.GetExecutingAssem... |
I have in my program a class with a member function that should treat certain objects slightly differently than others. In order to do this, it needs to know which object was passed to it, because these objects would have peculiar data pointed to by their data members.
But it seems that referencing the name of the invo... |
I'm a very new programmer developing my first application in Java as a side project for my employer. I'm a part-time student working full-time hoping to eventually score a developer job, and my employer encouraged this by allowing me to set aside some time daily to work on it. For the sake of anonymity, we'll call my e... |
So, I've been refactoring my videoconferencing application for a while, covering it with unit and general tests. Finally, I got to the point where I need to write a loopback test with 1 client sending video stream over to another client. This is not supposed to run as one process, even on the same machine. Nevertheless... |
Take the following sequence of events:
Business layer requests data x and y from data layer.
Data layer returns version 1 of x and y.
Business layer starts performing logic based on data x and y.
Another (concurrent) operation updates data x to version 2.
Business layer instructs data layer to save new data z based on... |
I am needing some assistance with designing with DDD.
I have three classes, Family, Child and event. Is the correct way to model this to to have Child in both Event and Family and make Family and Event an Aggregate Root.
My question is it ok to have an Entity as a member of two AggregateRoot?
public class Child: E... |
I ran into an error stating:
"ImportError: No module named 'pywintypes'", and after some reading around, I have discovered that the DLL for pywintypes is in C:\Python35-32\Lib\site-packages\pywin_32_system32 in the form of a DLL file. Others have suggested adding the path to system path. I am new and have no clue how ... |
This question is based on two premises:
First: an object must always have valid state. It is discussed in various posts, too. https://stackoverflow.com/questions/22408804/should-a-c-object-always-be-in-a-valid-state
Second: a class can exclusively trust itself to anticipate as to whether its instances will have valid ... |
I'm learning .net MVC while developing a simple word list - Eg. When you learn a new language and create a list of words related to a certain topic.
I don't think I'm following the rules or good practices of the MVC architecture.
It doesn't feel right that I pass the full Model to the view, which also contains methods... |
I have to start using versioning for my project which is a web app so compatibility isn't really a problem. I think using a
Major.minor.revision.build
is too cumbersome. I am almost convinced to do it with just the build number.
I don't care for hotfixes, feature releases, etc. This is a web app. I will never have on... |
Is it okay to group several Components into a single lifeline for simplicity?
For example, let's say I have a UML Component Diagram, and it's a layered architecture. There are 26 components, one on top of the other, component A to Component Z.
The interface to the system is Component A and the processing is in Componen... |
This is a blindspot in my understanding of REST. I understand how to make get calls (and Post) if the call is simple, and requires maybe a few parameters. Example:
https:\\randomAPI\get\coats\size:12\length:8
But what if I need to update a resource, and the request calls for multiple parameters, some of which may be... |
I am writing a Web application for copying files between servers.
I decided to write a WebSocket server which will receive and send relevant messages (that is communicate with a browser), start and stop copying processes.
Accordingly my design decision, there is at most one copying process for a given user. A user does... |
Consider this example class which in encrypting some data and sending it to some other service.
Consider the test for redirect method.
This is how you consume the class:
<?php
$safeLink = new SafeLink('some_secret_key');
$safeLink->redirect('http://external.service.com/receiver.php', $someData);
and the class is smt.... |
I don't understand the connection between type inference and advanced type systems. I don't see why Haskell or Standard ML or OCaml could not have existed without type inference. My only guess is that type inference might have been a trend in the 70s when ML first came out and the descendent languages simply kept that ... |
Everytime I press a certain button, it should remove a random index from a dictionary and then save that dictionary everytime its modified. I have done this using NSUserDefaults. I have found that all the info persists even after turning the app off and back on. Although, when I delete the app from the simulator or ex... |
In C++ Is using
this->data
slower than
data
?
|
I could not think of a better name.
I have a class called MoveObjects which holds position and move info.
Then I have two classes, Items and Attacks. Both have MoveObjects in common.
What I am trying to do, is loop through move objects and the loop determine if it is associated with a Item or Attack.
Basically (but can... |
As a comment on a response to this question, someone says:
It is not advisable to put the password in the URL for this file is saved on the .git/config . Is not safe, it is better to use ssh key
Why? Understanding the password will be visible if I type git remote -v, that it'll show up in my bash history, and that a... |
I have great trouble doing recursion, especially trying to visualize it. A great example is the aging wine problem described in the top answer of this link: https://www.quora.com/Are-there-any-good-resources-or-tutorials-for-dynamic-programming-besides-the-TopCoder-tutorial. In the example, you are tasked with finding ... |
As you know SQL doesn't have arrays. So if you make a table "article" and wish to have comments on your articles I presume you would make another table "comment". Inside "comment" table you have the content and a foreign key named "article_id" which points to the article's id.
So to get all of the article comments you ... |
How do I know if my code is running fast enough? Is there a measurable way to test the speed & performance of my code?
For example, I have script that is reading CSV files and writing new CSV files while using Numpy to calculate statistics. Below, I'm using cProfiler for my Python script but after seeing resulting sta... |
What are some good practices to do error management in a web application of about 30 people divided into 5 people team, where each team is responsible of a specific part of the application?
I am looking for answers on:
How do you make sure that new errors get addressed or triaged?
How do you make sure that current err... |
As someone used to C++ and new to JavaScript, I find this behavior odd. Whether a program runs directly on the platform like C++ ones, or it runs at a higher (or deeper?) level like JavaScript ones, conceptually, a program a program and an exception is an exception. Then why does JavaScript have this behavior? Is JavaS... |
While curiosing on the main page of a scripting programming language's site, I encountered this passage:
When a system gets too big to keep in your head, you can add static types.
This made me remember that in many religious wars between static, compiled languages (like Java) and dynamic, interpreted languages (mainl... |
All languages I have seen so far have multiple builtin data types (int, double, float, char, long...).
But if we look closely, they are just arbitrary arrays of bits, the only difference between them are their methods (addition, dividing, toString, etc.).
So why did all those programming languages decided to provide m... |
On pages 136 and 137 in The Clean Coder, Robert C. Martin describes how chips could be independently deployed thanks to a vtable:
The solution was pretty simple. Each chip had to be decoupled from all
the others. Each had to be turned into an independent compilation unit
that could be burned independently of all t... |
I've been reading the C++ for dummies book and I'm loving it! I'm on the section where he is talking about short circuit evaluation. Here is my understanding of short circuit evaluation.
Short circuit evaluation is only applied to bitwise operators, for example AND && and OR ||. So if condition1 is not true then the ... |
I have been studying software architecture and design patterns for the past weeks, and for a week now I can't stop thinking about the performance problems that come with the flexibility of the data mapper pattern. In the book written by Martin Fowler, he gives an example of the pattern with some find methods and just o... |
Given a list of items, what's the most efficient way of ranking those items with the least number of comparisons? Is there a name for this type of algorithm (that way I can focus my search)?
Also, is there a way to do this and receive a partially completed ranking in order (1st, 2nd, etc) that's still near-optimal in t... |
I’m creating an app that allows users to post, sell, and purchase items. Every item has a count integer attribute that is set by the initial user and which is reduced by n with each purchase. When count is 0, that item can no longer be sold unless one of the previous user buyers reposts the item they purchased: in whic... |
I am building a web spider to crawl through several different sites, but one of them uses javascript buttons instead of links for several functions. And while I could learn to follow them, it adds an extra layer of complexity I would rather avoid if possible. But, on the other hand, the mobile site, easily accessible w... |
I'm building an app for slack. While I've completed the POC, and everything works well for a single instance of the app, I'm having an issue of wrapping my mind around the scaling of it.
The specific issue is this:
the app utilizes the slackbot. A slackbot is a node.js app that opens a websocket to Slack with the rel... |
I have a number x. I know its prime factors and their multiplicity. Does anyone know an algorithm that decomposes it into all possible combination of its divisors (without respect to order)?
E.g. x=18 (prime factor , multiplicity): (2,1), (3,2)
Decompositions: (18) (1,18) (2,9) (3,6) (1,2,9) (1,3,6) (2,3,3) (1,2,3,3)
... |
Since learning object oriented programming I've been confused about how to deal with multiple ways of storing data that have different levels of functionality and efficiency. I'm kind of new to this so I'm probably missing something or approaching this wrong.
Say I'm writing a hypothetical image editing program (I'm no... |
I am going to create a stock market android app. Stock quotes change every few seconds, so to keep the app updated I decided to implement a reactive functional design.
My IDEAL design would be:
Everytime that the server has a new value for a stock, the app is passed the new data. Finally, the data is displayed to the ... |
I'm currently joining a project in which there's a core REST API already developed which is used for a mobile app. The next step will be to build a web app which should also consume the API.
My doubt is in which frameworks would be good for doing something like this. Normally I would use rails, but I'm not quite sure b... |
I need to strengthen my OOP skills and hence I thought to implement an Elevator simulator. At first what seem to be a simple design has grown into a complete mess and has left me confused about my knowledge of OOP. Below is the implementation classes.
/**
* 1. User enter the elevator.
* 2. Elevator checks the maximum... |
Currently um working in an application and it has the following hierarchy
WEB API2 Controllers (hilds the end points)
Business Logic Layer (Dedicated for business logic handling )
Data Access Layer (Repositories)
If we want to impose a validation which does not related to a business logic as for an example a character ... |
I have a MCU-based design that essentially controls other hardware and this MCU is controlled through an app. I was hoping someone could help me figure out how to secure this communication between the app and MCU. I've tried something like SipHash which essentially appends a hash of the message with a plain text messag... |
I have a java plugin written for a software called icy. Since the entry point of program is when the plugin is activated from the software, I am having trouble about how to mention that in manifest.mf file. When I give the main class (which has event handler and not the main method) it says resources not found.
How ca... |
We keep being told we are going to be working in an agile way on a new project by senior management. They have set up stand-ups, sprint planning, retrospectives etc. etc. However, they have now come up with a plan detailing all work they want us to deliver with dates against each element and showcase dates again with w... |
I haven't started building my back end yet but I need to now.
My needs are the following:
Database needs to be holding millions of game information (just info that can be stored in a typical db like match_id, win or loss, hero id #, item id # etc...)
Needs to be able to perform a basic division calculation based on c... |
Reading Ian Sommervilles's Software engineering, he mentiones there are following interfaces:
Paramater interface: data or functions are passed from one component
to another
Shared memory interface: block of memory is shared between
components
Procedural interface: interfaces where one component
encapsulates a set of ... |
I have a class that has several fields which can only be filled consecutively by a lot of calculation. The 1st field can be set very easily. To fill the 2nd field, we take the 1st field's content and calcuate a lot. The 3rd, 4th and 5th field must be calculated together from field1 and field2 (it is not possible to cal... |
Recently digitized and turned into a repo, the original Apollo 11 guidance computer source code has been made available for viewing on Github.
In MAIN.agc, the repo author comments that they
split the huge monolithic source code into smaller, more manageable chunks--i.e., into individual source # files.
A bit later, ... |
I'm writing an interpreted implementation of a new programming language (just for fun). In this implementation language is first being compiled to an intermediate language, which is then interpreted by an interpreter. Interpreter is written in Mono C#. However I got this idea to translate methods, which return no data ... |
I spent a few hours cleaning up a really old Python library, ProxyTypes. Two days from now will mark 10 years since it was updated. Today, I updated it to support the newer Python 3, and to be compliant with the PEP8 style guide. I've stripped out some of the code I don't need, but the functionality and logic of the re... |
This is a follow-up question of my previous one: https://stackoverflow.com/questions/38421950/better-class-structure-for-logical-expression-parsing-and-evaluation
Brief introduction:
rules as strings
combinations of logical-and, logical-or, logical-negation and grouping by parenthesis of identifiers (ID's)
Example: ... |
I am currently rewriting one of my projects in Java and want to implement a service layer that will be used by different clients (CLI/GUI/Web) to communicate with my core application. For now it will mostly just delegate the same calls to the Business Model, but I want to add User authentication later on and I read, th... |
I have a bit of a problem regarding implementing Scrum into a project. The team I'm working with is generally just very bad at coming up with ideas. I'm not sure if it's a matter of them not feeling comfortable with the environment or what.
I've worked with them before, and they actually work best under a Waterfall de... |
I want to sell my source code, it's written in PHP and CodeIgniter. And it's actually a CMS for personal website.
My intention is to create only one license for one use only, if someone buy this code and install it on his/her server, then when he/she tries to install it again somewhere else, it can't be done.
Software ... |
I am currently looking into re-architecture of some of my organization applications. Other questions aside, the one that I am currently trying to figure out the best approach for currently is the application communication. Here's the current thinking:
Client Application (UI client) - handles user interaction
Admin App... |
Today we are working with Stored Procedures to access the database.
In order to allow unit testing, we implemented an interface for each group of related stored procedures, for example:
ICustomerRepository
{
GetAllCustomer();
GetCustomerById();
GetEnrolledCustomers();
// etc..
}
We plan to implement DDD in all pro... |
Let's say you have a software solution that has a data layer that accesses a SQL server. It can do this either directly and also over a HTTP connection. In both cases Datasets are used.
Now when migrating away from Datasets to a more modern technical solutions of course using an ORM framework might be the natural choic... |
Given k sets ,each contain several elements .
I want to split them to two groups ,
the first group contains m sets ,the second group contain n sets , m + n = k .
Let w1 be the sum of the weights of all the elements in the union of the first group of sets .
and w2 be the sum of the weights of all the elements in the uni... |
I've been recently thinking about the following question:
When are requirements good enough for implementation?
I'm trying to create a checklist of some sort that can at least semi-objectively answer this question.
Here are some of my thoughts about methods and checks to ensure good requirements:
Ambiguity Poll (are t... |
I'm working on the import of land-use data into Openstreetmap. Unfortunately I've encountered a problem that has delayed my time table.
Take a look at the picture below: the red line is the main road (it is correctly mapped using GPS devices). The white area is the region that indicated the presence of the road: it sho... |
I frequently come across projects that strictly define an interface for each and every class. 90% of those interfaces feature only a single implementation. Proponents of these "preemptive interfacs" defend this approach as follows:
In Java one should always program to interfaces to minimize refactoring efforts, when a... |
I am generating a 2D "world map" in Unity which I use C# and Perlin noise for.
I have a Tile object that holds the graphic of the tile and position. There are a few more attributes to this class, but they are not of importance here. I have provided the base implementation below:
public class Tile()
{
public GameO... |
In gitlab, there is Merge Requests (MR) like in github there is Pull Requests (PR).
If the MR is rejected, sure, we close it.
But what if the MR is merged ? In that case the button to close the MR stay available.
So, what is the right way ? Should we close all MR at the end of the story ? And if so, when to close it ?... |
I am looking for advice on how to design the following scenario:
I have a 3-dimensional vector class, the entries are of type double. I want two vectors to be considered equal if their corresponding elements differ by less than a given tolerance, e.g. 10^(-10).
(Code examples are in C# syntax mixed with pseudocode.)
pu... |
Given the following code snippet in a Laravel Controller:
$this->userRepository->saveByProject(
$this->fileRepository->saveByProject(
$this->metricRepository->saveByProject(
$this->projectRepository->saveByUser(
$request->attributes->get('user'), $request->all(), $id
... |
Currently we have about 20 solutions. The majority of these have multiple projects, including share utils projects, data access, etc. We've had a few problems where a contractor changed something in a common project and unknowingly this breaks a number of other solutions. We currently have 7 perm developers and 3 lo... |
I'm refactoring a huge WPF application whose complexity stems from the way it deals with flow control. It has a lot of "tiny business rules" that make it really difficult to make a modification without breaking something. These rules are things like
If the window mode is foo but this is the first time they've pressed ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.