instruction stringlengths 34 36.1k |
|---|
I often wonder why Java uses :: for method references instead of ., e.g. why write
System.out::println
instead of
System.out.println
Of course, one might simply answer: "because the designers decided so". On the other hand, I would have expected the second syntax because the dot is the usual Java syntax for acces... |
I am writing a simple Java app to run weekly. The app need call database to get data, check it and update.
The flow I need is little as following:
select configure,orgID where status=true from orgs;
orgs has thousands of rows, configure is blob
Check blob object configure, and filtered the orgID list
for filtered or... |
Let's assume I have two classes that look like this (the first block of code and the general problem are related to C#):
class A
{
public int IntProperty { get; set; }
}
class B
{
public int IntProperty { get; set; }
}
These classes cannot be changed in any way (they are part of a 3rd party assembly). There... |
Is it ok if I include many PHP file within a PHP file? What is the best practice? Or where can I learn the best basic practice of writing PHP?
Why I do this
Is because I often can change the content of each div through the PHP file instead of directly change in the main PHP file.
|
I'm writing javascript object that wraps REST requests. For every operation on the server there is a method that accepts the parameters for the request and a callback that will receive the results. (The method issues a jQuery $.ajax()-call and prepares the settings for $.ajax().)
Each method has the same structure: c... |
I have a strong Java/Groovy background and I've been assigned to a team that maintain quite a big C code base for an administrative software.
Some pain points, like dealing with blob in the database or generating reports in PDF and Excel have been externalized to java web service.
However, as a Java dev, I'm a bit co... |
We are currently devloping a ASP MVC Webapplication. In this Webapplication, we have a User that can have 1 or many contracts.
We currently have 2 controller:
UserController
ContractController
Now we want to display all Contracts for a User. Which of the above Controllers should contain the Action to List all Contrac... |
In our application, we have a pojo mapped to some entity. One pojo refers to one entry in DB. There are multiple steps for it's life-cycle. It gets created freshly, it goes 'live', after some calculations it either gets disabled or goes 'live' for something like plan B processing and then finally ends it's journey.
Pro... |
I read somewhere that C is preferred for drivers and firmware on embedded systems because it requires less run-time support. I could not understand the part 'run-time support'. My understanding is C code is converted to assembly code, which is flashed on a embedded device in form of a binary file. Please correct me, if... |
How is Bytecode "parsed"?
It is my understand that Bytecode is a binary, intermediate representation of the syntax of a given programming language. Certain programming languages convert their source text into Bytecode which is then written to a file. How does the Virtual Machines of those languages "parse" their Bytec... |
Say I have the following ER diagram:
Now if I represented the relationship using a foreign key of School in Student, I could have NULL values (because a Student
is not required to belong to a School), for example:
So the correct way (based on what I have read) is to create an intersection table to represent the relat... |
I am trying to wrap my head around having a secure WEB API and at the same time securing the client that accesses the WEB API. I am hoping someone can point me in the right direction.
Here is my scenario. I have developed a WEB API that has an authentication method that takes a username/password and upon success authe... |
I am writing a small program that is a client of some protocol. I wanted this program to have a filesystem database. the main directory would contain one directory for a server that is configured, and the server directory would contain things like server settings in json and other data, this time those are certificates... |
We work on a fairly large casino/gaming/wallet/lottery platform. It's a turn-key application that is currently in use by 4 clients, and soon to be much more. I've made some bullet points regarding the architecture below:
~130K LOC in just C# code
over 500 stored procs, in one of the 5 databases our system uses - becau... |
I've created a Java project based on a C# sample application that was published under the Code Project Open License (CPOL) which sounds to me quite similar to MIT.
As I was the only user of this library for a while I didn't care too much about the concrete licensing. However, I was asked recently to choose one so other... |
Using gitflow, when creating a release-1.0.0 branch and merging it to both master and develop, both branches will have a missing commit:
master wont have the commit where release-1.0.0 was merge to develop
develop wont have the commit where release-1.0.0 was merge to master
Instead, after hotfix-1.0.1 is created and ... |
I have heard this term a couple of times. What exactly does a Cloud-Native application refers to? What are the features of a Cloud-Native applications?
|
Java 8 added the concept of functional interfaces, as well as numerous new methods that are designed to take functional interfaces. Instances of these interfaces can be succinctly created using method reference expressions (e.g. SomeClass::someMethod) and lambda expressions (e.g. (x, y) -> x + y).
A colleague and I ha... |
I'm a front-end web developer and currently facing a situation where I have one form with few parameters of one object and to save them I should make few requests to few different API endpoints. As I'm used to REST ideology I suppose to have only one API to save one resource.
There is some entity, some object with huge... |
The Problem
We are currently architecting our new Notification Microservice but having trouble with how to handle aggregated emails. What we need to do is instead of sending one email every action performed (could be 20+ in a few minutes), we would send an email after an hour summarizing all the actions that were compl... |
I started a new job recently where I am working on a very large application (15M loc). In my previous job we had a similarly large application but (for better or for worse) we used OSGi, which meant the application was broken down into lots of microservices that could be independently changed, compiled, and deployed. T... |
I have a situation where my ASP.NET MVC application can be loaded directly or in iframe. It uses ASP.NET Identity. When I open the site from iframe, log in and after open the site directly it keeps me logged in. Is that a normal behavior? Is session shared between apps opened directly and in iframe?
Here are more detai... |
We are developing the application with MVC and Repository Pattern. Currently we are using EF as an ORM. But Later we need to change the ORM to nHibernate.
Any Idea on the architecture.
Currently I plan the architecture as
Contracts:
Model/Entities/Repository-Interface/Service-Interface
DataLayer(Reference Contracts... |
The following code says that c1 == c2 and c2 == c3, but c1 != c3.
TOL = 0.11
class C:
def __init__(self, x):
self.x = x
def __eq__(self, other):
return abs(self.x - other.x) <= TOL
c1 = C(1.1)
c2 = C(1.2)
c3 = C(1.3)
print(c1 == c2) # True
print(c2 == c3) # True
print(c1 == c3) # False
F... |
I can write code like:
var dependency = "Hello!"
var something = new Something(dependency);
something.DoStuffWithDependency();
Or I could write it like:
var dependency = "Hello!"
var something = new Something();
something.DoStuff(dependency);
Where the first example takes the dependency in the constructor and uses it... |
At my workplace we're soon going to be tasked with removing SQL injection vulnerabilities from a large code base. The application was originally written around 8 years ago and after years of bolt-ons and additional features, security is finally getting looked at. We'll be moving from using the mysql_ extension to PDO a... |
I was wondering if anyone out there has general tips for how to structure an iOS app backed by a REST api. There are basically two approaches to this that I've thought of
API calls placed ad hoc in the view controllers.
In this approach the view controller has some state that it fetches from the backend such as a Use... |
I've been reading the OAuth 1.0a RFC: https://www.rfc-editor.org/rfc/rfc5849 . Most of it is pretty clear. However, I have a few questions:
I can't understand why the oauth_callback is sent when obtaining an unauthorized request token. I mean, doesn't it make more sense for it to be sent when redirecting the user to t... |
Let's say I have this example. There is a chef (actor) and a Use Case cook food. If there are 2 food options to cook (lets say pasta and pizza). Should I create 1 Use Case : CookFood and then in variations section add Pasta and Pizza, or should I create 2 use cases : CookPasta and CookPizza.
|
Apologies if "Composition Hierarchy" isn't a thing, but I'll explain what I mean by it in the question.
There isn't any OO programmer who hasn't come across a variation of "Keep inheritance hierarchies flat" or "Prefer composition over inheritance" and so on. However, deep composition hierarchies seem problematic as we... |
I am learning about the Crow's Foot notation, and there is something that I don't understand, some tutorials shows an Identifying Relationship as having a straight line, and a Non-Identifying Relationship as having a dashed line:
While other tutorials shows both relationships as having a straight line:
Are both notat... |
I would like to solicit some general design principles and best practices to avoid creating a callback pyramid of doom particularly in the Scala language.
Consider the following rudimentary and imaginary code snippet:
val response: Future[Either[ApiError, Option[CogWidget]]] = services.findCogWidget("Some-UUID-42")
res... |
Let's say that I have a chatroom application that manages rooms, users, and messages. I'm building this out as an opportunity to practice some service/manager/web separation and teach myself good application design.
With the following classes:
Model:
public class Room {
private final String id = UUID.randomUUID().t... |
My client has a super Spaghetti codebase structure. Single solution with some hundreds projects in that solution, which are tightly coupled.
They think that just using a package manager (like NuGet) is a solution to their problem, they want to create packages from their codebase and put them in their internal reposito... |
Lets say I have some sort of unit tests like this:
let myApi = new Api();
describe('api', () => {
describe('set()', () => {
it('should return true when setting a value', () => {
assert.equal(myApi.set('foo', 'bar'), true);
});
});
describe('get()', () => {
it('should return the value when get... |
Sometimes I work for a project that requires some programming languages for about 3 months, later I work for another project that requires a different set of languages. I know and studied of of these languages, but the problem is that I keep forgetting a lot of the details, and sometimes I have to re-read a book or wat... |
Currently I'm investigating about NCurses library for implement text user interface in C programming language.
Curiously today I went to a Car'ls Jr and and there was a monitor like this:
Now, my question... is this a terminal application (TUI), why this kind of companies (fast food) use text based applications (it lo... |
I am designing an Information System for the French Social security system and would like advice on how to use Ishikawa (fishbone) diagrams to model said information system.
My question specifically is about the definition of "environment" in this diagram. What is the common definition for "environment" in such diagram... |
We have an mvc application that we would like to gradually move to an angular platform. It is a wizard style app with 6-8 pages.
We currently have a classic mvc layout. We would like to move to an angular2 project structure.
Our current approach is to rewrite one page at a time, but we also have to provide improvement... |
I am a bit confused regarding module loaders Like I am using webpack which load modules as chunks but it is only while developing When the code gets minified it will be a single file for all scripts and css and there how the module loaders work?
Any explanation would be appreciated
|
First time posting.
I know this is a very generalized question, sorry for that, I don't know how to more appropriately word this.
I've noticed a trend, a pattern in methods, it seems in almost all methods, for example, in Java (haven't programmed much in other languages although I would imagine it's the same) the metho... |
I'm studying for the CPRE Foundation Level exam from the International Requirements Engineering Board. In the exam, there is a statement:
Quality Requirements are elicited after the Functional Requirements.
The answer to this statement is provided as false. Does this mean that quality requirements should be elicited ... |
I run an automated data collection service at work, which records measurements (temperatures, voltages, etc) from about a dozen sensors at a rate of about once a second. The MySQL database table looks like this fictitious example:
TABLE: recorded_measurements
**************************************
id sensor measu... |
I was reading the post A Modern Architecture for FP that included a code snippet that the author wanted to decompose further. I don't know Haskell but I recognize enough to know that I've written many functions like this one, combining related logging, metrics, and business logic in one function:
saveFile :: Path -> By... |
Okay, I'm trying to write something resembling a 3D game engine. That means I have to deal with matrix transformations and similar stuff.
For any of you who don't know, you need to use three basic matrices to define where a vertex will be positioned on the screen: projection matrix, view matrix and entity matrix.
View ... |
while cond1
...
if cond2
...
else
...
break
The while loop above has two termination conditions,
cond2 and !cond1
!cond2
When the commands that are represented by ... are long,
I feel the code is not easy to understand.
The two termination conditions for the same while-loop are f... |
When you want an overrided method to take as argument a subclass of the argument of the overridden method, you usualy accomplish that with generics (as discussed in Template pattern with varying input type in overridden method). An example of that can be seen in my methodA of the class Parent and Child
I am wondering i... |
I'm developing an Android app whose architecture is based on the well known Uncle's Bob Clean Architecture.
I have the following Use Case:
Validate User Subscription
It's based on this use case descryption( main success scenario)
Check if validation warning was already shown
Yes -> Go to step 6
No -> Go to step 2
Ch... |
In the game I am working on there is a Match object and a Player object.
The game is divided into different Matches (basically a lobby). Every Player needs to be in a Match but cannot be in several Matches at once.
Match contains the method List<Player> getPlayers() (list of players connected to the match). Player cont... |
I'm trying to improve my understanding and ability to write code that uses recommended principles and practices, such as the SOLID principles. To do this, I am implementing the fireworks card game Hanabi.
Hanabi has two deck types, Standard and Advanced (which has an extra set of MultiColour cards). Each card in a deck... |
I want to license my Minecraft mod with WTFPL. However, I have a small section of code which I incorporated from other mod, licensed under GPL, in the first release of my mod.
In the recent version (see dev branch of my mod) I refactored and rewrote it from scratch. I also got permission (see README of my mod) from th... |
I am trying to draw a sequence diagram for "post a job" use case.
The description is as follow:
Basic flow:
This use case begins when the employer selects the “Post a new Job” option.
System displays the job form.
The employer fills the form with the following information:
Job title,
type and category (selected from ... |
I am making a game. In this game people can modify a value of an object. Let's picture it like so.
House is the object
price is the value
Mold is the modifier
Should I reflect changes to the price of the house in the database by directly altering a size column.
UPDATE house SET price = price - 2 WHERE id = 1;
Or shoul... |
Could you explain how parsers search for token patterns like in markdown?
I probably could come up with something matching only the braces pattern []() as soon as nested patterns are involved it blows my mind.
For example in something like this
foo [**baz**](baz) qux
the tokenizer probably explodes the string into the... |
Say I have the following ER diagram:
Enforcing the mandatory participation constraint at the one end is easy, I simply make the foreign key (school_id) in Student NOT NULL.
But how can I enforce the mandatory participation constraint at the many end (each School must at least have one Student), that is, how can I prev... |
I have a class called Canvas that acts as the container for a number of Rectangle.
The Rectangles have the following behavior:
They can be moved within the Canvas.
They can be resized.
They may not overlap, move over each other, or move past the boundaries of the Canvas.
The side of a rectangle can be attached to the ... |
Languages like C, Java, and C++ all require parenthesis around an entire expression when used in an if, while, or switch.
if (true) {
// Do something
}
as opposed to
if true {
// Do something
}
This seems odd to me because the parenthesis are redundant. In this example, true is a single expression on its own.... |
When trying to learn about proper comment practices, I found a lot of conflicting opinions, and it's obviously a very subjective topic. So I'm not going to ask "Should I comment, or should I not?"
The question I'd like to pose is, for me, as a self taught developer interested in applying for programming jobs in the fut... |
I have a legacy MySQL Database (A), and a new reviewed structure for MySQL data base (B).
Problem number one is that Database has to be alive and keeps receiving data from legacy apps.
What I need is to constantly move data from old data structure to the new one. Moving is not 1:1 but it is subject to data transformati... |
I have a piece of software which has different users (admin/user) In the admin version you are able to upload the changes straight away. Whereas a user doesn't have this ability have to save it to get authorisation. To display the options I wrote my code like this.
actionMode = ActionBarMode.SaveCancel;
... |
I am working on an embedded C project where there is a function used to initialise a module's (foo) context object handle. Thus when testing using the Ceedling I have used this initialising function in the set up:
#include "unity.h"
#include "mock_bar.h"
#include "foo.h"
static foo_handle s = NULL;
void setUp(void)
{... |
I'd like to decompose a number of Java REST services (WAR files) into individual container-ised "MicroServices" - so that I can scale services ondemand, insulate the applications, have loose couplings, facilitate cloud deployments, etc, etc (roughly ~100 services currently being used in an ESB/running in the same JVM)
... |
I want to wrap every next web application with A top menu and right menu like this :
Every new application should be integrated in this master wrapper.
I thought to create a master page for the wrapper but i will have to create a similar master page for every new application.
My question :
What's the suitable patter... |
If I have "Object" as the top level class, then I have various interfaces, ISomething, ISomethingB, ISomethingC, then I have Class x,y,z, all ultimately deriving from the class Object (these subclasses don't have to derive from each other), wouldn't me having one class at the top like "Object" in .NET lead to, or possi... |
In order to develop an Information system, my system will contain web, mobile and desktop applications. My idea is to make one web services , because for mobile phone apps it will be better to use a web service to manage database and do the heavy width processing also to reuse code in other apps.
In other hand for the ... |
I'm working on a TCP HTTP proxy: need to turn it in a priority proxy.
The standard proxy used to deal every connection with a fork and the child process handles the connection. Now I've implemented a priority queueing mechanism where packets coming from both sides of connections are queued and dequeued: packets coming ... |
In quite a few object oriented languages, especially the ones without free standing functions, it's now best practice to have one class per file, with the file name being the same as the class name. E.g. MyClass.cs storing class MyClass - this kind of makes the concept of a file pointless.
Is it known what the reasons ... |
I'm creating a Node app.
I have JavaScript files that include custom functions that make calls to external APIs (in this case Google APIs)
I have JavaScript files in my node app that are related to setting up the web app and using these custom functions described above
What would be a good name for these JavaScript f... |
I've been thinking about how to design my WPF application, which receives data from a WCF duplex service, but I'm afraid of over engineering.
I thought about abstracting away the WCF communication completely from the WPF client by creating a "proxy client" library that implements the service and callback interfaces int... |
Consider a module with a 'public' function which looks something like this:
def func(arg):
val = _generate_something(arg)
_do_something(val)
As you can see this is a 'void function'. Its core logic is in _generate_something.
I want to write unit tests for this function. I can think of several approaches to do ... |
Which programming languages support type inference from variable names?
By 'type inference', I mean, for example, in Swift, how if you let x = 39 then the compiler knows x is an Integer, because 39 is an integer.
Now, it's conventional in Swift to use the keyword is at the beginning of Boolean variables. For example l... |
When I was reading about microservices on this site, I came across the below statement. What is meant by a canonical schema? Isn't it same as domain model?
The Microservices Architecture pattern also rejects other parts of
SOA, such as the concept of a canonical schema.
|
Disclaimer: Although I mention my use in matlab I think this is is more of a programming pattern question so I put it here. If I am incorrect I will be happy to go over to stackoverflow.
I have a variable comprising of strings array which acts like a database I need to refer to in several functions in my program. It ge... |
I'm trying to design a database for my POS application and have stumbled when trying to create an address table. I'm confused whether to have city and country tables with predefined values and link the pk to the address table (city_code/country_code) OR just have city and country columns as string and ask user to enter... |
I have a class called Heading that does a few things, but it should also be a able to return the opposite of the current heading value, which finally has to be used via creating a new instance of the Heading class itself.
I can have a simple property called reciprocal to return the opposite heading of the current value... |
We are trying to improve our continuous integration pipeline and moreover improve how quickly we can get code through from inception to production.
We have tests at different levels that verify what our software is supposed to do functionally e.g. if there were 20 primary use cases, we have those 20 primary use cases ... |
I've encountered a problem which I think is rather suited to be solved using a Constraint Satisfaction Problem algorithm.
I am however, not entirely certain that this is the best approach, as the specifics seem to deviate a bit from the classical CSP problems.
The problem:
I've got a list of entities that I need to ma... |
I'm working with Swagger to generate the API of my application. Swagger is an API specification language that can be used by a code generator to generate code stubs for your application. Obviously you have to complete these stubs with some business/controller logic.
Given that the code generation is an iterative proces... |
I have a Category and Product tables in database and classes on project.
Category class has {id, Name} properties
Product class has {id, Name, CategoryId} and other relations.
And I have repository and service layer.
So if I need to get products of a category, where can I put this logic?
Category repository => GetProdu... |
Background
I have recently taken up a new job as a developer at a company where I have inherited an in-house CMS built approximately 5 years ago. The CMS constructs pages in XML which are then output to the page as HTML. Some of the markup is generated within the back-end PHP, whereas some is exposed to the user in the... |
Introduction
I am working on MyProject which is windows (desktop) application being developed in C#.NET and DotNet Framework 4 in WPF. Project is layered as DataAccessLayer (DAL) --> BusinessLogicLayer (BLL) --> ApplicationLayer (UI).
This project has a module called MyModule which needs to be reused in other multiple ... |
We've a table which has a bunch of columns. Let's say it represents humans. Every human has a specific type: archer-human, car-human and so on. Everytime we create a row nearly all of the fields are empty since we create a human of one type only.
For example:
| ID | Forenamne | Surname | Arrows | Bow | Car-Manuf... |
The project I am working on has deep parent/child relationships that needs to enforce availability.
Imagine we are a large Worldwide Electronic Seller (Best Buy) and selling mobile phones
We have Regions (Asia,Europe,North America..), Countries within Regions, Warehouses within Countries,Stores which are working with W... |
Is it weird to have an identifier such as (_id) on a request which you send to the API, which "enriches" the request and sends back a response with the same identifier (but obviously more enriched data)?
For example - you send request {_id: 1111} and get back a response {_id: 1111, occurence: new, etc}.
The reason why ... |
We use SVN for our version control and have a trunk for minor changes and a branch for more significant changes and also for the devs to be able to work off the same code base.
We regularly do trunk merges so our branch code-base stays up to date. When we work on a given bug / issue we do so generally on the branch and... |
When doing (possibly heavy) pixel processing on a large image, multithreading becomes a must. The standard practice is to initiate a loop whose indices are partitioned into multiple threads within a thread pool. The performance benefits become immediately apparent after taking the appropriate thread-safety measures to ... |
I recently got into website development and am in the process of making my first website using Angular 2 right now. I already created websites in the past using basic HTML and PHP but that was nothing special and the quality of code was pretty low. "Back in the days" I just created different files for different tasks, ... |
I have seen lots of advice about git branching models and the most common opinion seems to be that making changes directly on the master branch is a bad idea.
One of our co-workers is quite happy making changes directly on the master branch, and despite several conversations, they seem not likely to change this.
At thi... |
I have a system where a set of Operations needs to be done every day. Each Operation has the following metadata: Type, Entity and a Date (independent of current date). It reads something from the database, computes stuff and saves results to the database. An Operation is a combination of: [Entity, Type, Date]. I need t... |
We overestimated our project and are going to finish two weeks early.
Rather than fill in the extra time with additional features, management has directed the development team to use the extra time to ensure the highest possible quality code (Note: The QA team is not yet engaged.)
In what structured activities could th... |
I was reading about gzip program and I found the official website of the gzip software.
First of all the site looks very bad, it is very hard to find useful information on it and it was not updated since several years ago.
Also, only www.gzip.org is working, but simply gzip.org is not working.
It would not be hard for... |
I work for a franchise and we want to provide some web applications that host internal & proprietary information & functionality that should only be available to active franchise employees. Each franchise is independently owned and operated. They provide their own desktop computers (we require specs, like Windows OS) t... |
TL;DR: My question is about how to use in conjunction:
the dependency injection design pattern
with global / immutable objects (ex: a session that references a customer object)
I get the idea of dependency injection and immutable objects. They are great concepts and help implement good development practices. Is there... |
I have used a lot of JavaFX and am familiar with the technical aspects. Now, as I foray into a very large application with hundreds of views, I want to make sure I start strong with a solid design. This is purely a client application, backend is elsewhere.
I should also mention this is an MDI (Multiple document interfa... |
I'm designing and developing a learning system based on flashcards and leitner system. The system have many features such as creating flashcards, studying the flashcards, doing tests and etc. The activity diagram of studying the cards is attached below. It goes through all decks of the box, studies the cards, which are... |
During the design stage, I usually come up with a class diagram that looks something like this
However, during coding stage, I would never create a class like Librarian with issueStatus() or searchBook() method.
100% of the time, class Librarian, will be a plain-old-object with only getter and setter method, and issu... |
I'm working with Laravel queues lately.
I've all set up and running fine.
What I see is that I perform a http request to my system, the controllers manage the request issuing a Model having request details as parameters.
The model is the injected in the Job, then job+data(model) are serialized in my queue. (I'm using D... |
I've got an API endpoint which looks like this: http://foo.bar/rest-method/{identifier}.
This API returns an object that looks like that:
{
name: "Example",
version: "1.0.5.3937"
}
Now I know that the entry with the identifier 2923711253 has got version 1.0.5.3937 while the entry with the identifier 29238230... |
I've already an offline updater as a download but I want to make it automatically. It's a client/server software and a ms sql database.
3 parts have to be updated:
update of a proprietary software (setup.exe with next, next, type login/password for server service, finish) which delivers a WinClient and a Service for t... |
This question is on program architecture and relationship between DAL, Security and BLL in case, when simultaneous write in several storage objects is needed. I address it to Microsoft SQL Server functionality, but it is more common question and in general does not depend on used (R)DBMS.
I have read this Q&A:
https:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.