java – Naming conventions for classes that technically could/should have the same name

Sometimes such classes would be named as Base- or Core- to indicate that they are to be extended in other implementations, so you’d have CoreBoard and CorePiece.

Depending on the language you’re using, you could also use namespaces to distinguish between the two sets of classes. You could have a namespace for the Engine, and other namespaces for specific implementations. For example: jaylawl.games.engine.Board for the Engine’s Board, and jaylawl.games.chess.Board for your Chess board.

Personally, I prefer the second option, but that may be language-specific.

java – Spring boot, n-tier layer structure naming conventions

I am currently developing a huge project in my company with N-Tier Layer architecture using spring boot but I can not sure about the package and class namings. In our project, we have a complex structure. For example, we have to call oracle plsql procedure/function, pure sql, jpa with basic jpa repositories, web services calls(soap/rest) because of the requirements. For example;

I have to call procedure/function/pure sql with RestTemplate
I have to call rest web services with again RestTemplate
What is the best approach for naming the returning results, classes?

When a client calls a web service in our project, we decided to name the request XRequest, later we map the request objects to the XInput(it contains headers etc.) object with our necessary parameters and passed them to the service layers.

In the service layers, we call necessary other layers.

In these layers, after calling the other layers and returning the results, the procedure call, we map it to the XOutput in the Service Layer with required parameters, we passed XOutput to the Controller Layer, and the Controller Layer map the results to the XResponse objects with the required parameters.

enter image description here

In the above sample structure, what is the best approach of the returning objects’ naming in the Web service/custom repositories. What is the naming of the Class naming(such as Custom Repositories, DaoFactory etc.). What should the naming of the web service call returning objects?

To sum up, in this kind of unstructured project, what is the best approach to the naming conventions of the classes and packages.

Broker queue and topic naming conventions

I’m in the process of adding a message broker (ActiveMQ Artemis) to a system currently and while I have my own notions on how I can divide up the namespace, it seems like a good time to get opinions from others on how they like to name their queues and topics.

The overall topology I’m after is to support functionality grouped in two ways:

  • By technology and/or library. This is when messages that enter the system are defined by a specific application level library. Think Laravel queues, or Mass Transit in .net. This first convention allows me to sequester message activity on the broker per-library as they often feature proprietary conventions and function under the assumption that they own their messaging space exclusively.
  • By business domain. This one is a little more abstract, but is defined by the various sections of my ecosystem. It’s intended to facilitate messaging between applications that might be written in different languages. For example, perhaps I have a queue name of my-org:identity and this represents general user activity (CRUD). I might also have a my-org:blog to represent events and activity on blog posts that I wish to broadcast and react to. These could be subscribed and published to using libraries built around protocols like AMQP or STOMP, etc. from within different languages.

Acknowledging that you can’t 100% predict the future are there any insights, lessons-learned and intuition worth heeding when coming up with naming conventions within a messaging system?

Are there any good books, blog posts or articles on devising sound schemes for names on brokers?

coding standards – Classification of Language Specific Naming Conventions UseCases for Identifiers across Programming

For consistent and better readability, certain naming conventions needs to follow while defining identifiers which denote variables, types, functions, and other entities such as classes, methods, constants, triggers, delegates & so on.

It is often ambiguous for an experienced/beginner programmer to follow certain coding naming convention standards, in-certain times,
when migration occurs altogether to different programming languages

+--------------------------+-------------------------------------------------------------+--------------------------------+
| Formatting               | Name(s)                                                     | Language-specific conventions  |
+--------------------------+-------------------------------------------------------------|--------------------------------+
| namingidentifier         | flat case/Lazy Case                                         | Package names for Java         |
| NAMINGIDENTIFIER         | upper flat case                                             |                                |
| namingIdentifier         | (lower) camelCase, dromedaryCase                            | Variables for Java, C#         |
| NamingIdentifier         | (upper) CamelCase, PascalCase, StudlyCase, CapitalCamelCase | Class Names                    |
| naming_identifier        | snake_case, snake_case, pothole_case, C Case                | Variables at Python, PHP, etc. |
| Naming_Identifier        | Camel_Snake_Case                                            | ?                              |
| NAMING_IDENTIFIER        | SCREAMING_SNAKE_CASE, MACRO_CASE, UPPER_CASE, CONSTANT_CASE | Constants, Global vairables    |
| naming-identifier        | Kebab Case/caterpillar-case/dash-case, hyphen-case,         |                                |
|                          | lisp-case, spinal-case and css-case                         | CSS, HTML5 attributes          |
| NAMING-IDENTIFIER        | TRAIN-CASE, COBOL-CASE, SCREAMING-KEBAB-CASE                | ?                              |
| Naming-Identifier        | Train-Case, HTTP-Header-Case                                | ?                              |
| _namingIdentifier        | Undercore Notation (prefixed by "_" followed by camelCase   | Accessing Private Members      |
| datatypeNamingIdentifier | Hungarian Notation (variable names Prefixed by metadata     |                                |
|                          | data-types which is out-dated)                              | Eg.: strGradeOfCustomer        |
|--------------------------+-------------------------------------------------------------+--------------------------------|

For instance, when designing a schema such as tables, the initial seeding of attributes in a table will vary according to language-specific Frameworks for the one who has opted. I find there are many low-code/no-code in certain projects when a developer begins to code on new technologies.

  • Eg.: DateOfBirth, date_of_birth, dateofbirth field/column(s) name in
    a table.
    Adopting CamelCase styles in declaring variables & functions
    in various JS libraries, Likewise, Kebab Case style for CSS & their
    property names, HTML5 has it’s own attributes like data-element,
    data-count, and Often PascalCase is used by C/.NET Programmers

To achieve maintaining consistent, well-structured & organized code for readability.
What must be the Identifier names to be followed across all the programs?

plugins – How to handle autoloading with composer by keeping the WordPress naming conventions?

I’m a bit confused because I’m programming a plugin for WordPress by using composer as it’s the real way to go.

So I’ve created a composer file inside my plugin and some other stuff. In the composer file I’ve added my namespace for autoloading:

"autoload": {
  "psr-4": {
    "Johnny\Lolkick\": [
      "includes/classes/"
    ]
  }
}

Inside my classes folder I’ve created now a class with the name class-main.php. I’ve decided to take this name because of the WordPress naming conventions:

PHP Coding Standards

The class by itself was named class Main {. Inside my base plugin file I’ve created now a new instance of my class which failed. After changing the file name to Main.php it worked.

So in result the WordPress naming convention broke the autoloading of composer. I want to know now how do you handle this problem? How should I keep the naming convention by using composer?

What naming conventions should be used in cloud services (e.g. AWS)?

I have been using AWS lightly for the past few years, such as email forwarding, file storage, machine learning.

It is unsettling to have the flexibility to name policies, users, resources literally anything I wanted. I might have users and resources with very similar names. I don’t have a naming convention. When I look back at the resources I deployed previously, their names are not very helpful and I’ve forgotten what they are for, having to dig deeper into them to identify them, meaning the names are currently useless.

How do you handle this problem, and are there any resources to help me with naming things in AWS?

Naming conventions for set/unset method parameter

I have some class

MyClass

which has two methods:

Lock(){}

and

Unlock(){}

So far so good.

Because of reasons, the two methods are to be unified into one.

What should be the name of the parameter?

SetLockState(bool isLock)

or

SetLockState(bool isLocked)

or other?


This happens a lot in our code base, and I favor isLock, because it is the new state, but it seems there is some convention about isLocked which I am unfamiliar with, and would love an explanation as to why isLocked is the standard.

gm techniques – Mind-maps conventions, best practices and approaches

I encountered this issue when prepping for a big arc in my campaign, let me explain:

The players are entering a place where there are three main factions (A B C ) and possibly minor ones (D E). The factions have interconnections with each others: ( X1: if the dragon appears A does attacks B; X2 C tries to do steal from A’s vault) etc etc. On top of this, the actions of the characters influence what each faction does with the characters and with other factions (X3: if the characters contact B first, A knows and resents them etc etc).

Now, i wrote this down in prose, with a bit of structure etc etc but there’s a good chance to miss things when the list of X1, X2 … grows too large. For example, something in X1 may be influenced by something in X10 that is way down the prep page.

Question:

What are better practices to deal with this kind of mind maps? (i’m not really asking for what has worked for people but rather if there are resources that explain how to do these mind maps and why doing them in certain ways)

I can envision having arrows between Xi and Xj when Xj refers to Xi, but there may be also different kinds of relationships between different Xi and Xj (will differently-coloured arrows suffice?).
So, i don’t know if the text + arrows is the best approach, the clearest or whatever.

Perhaps this is a known concern when writing story/prep and there are some guidelines ?

javascript – Does my graphics engine code follow good conventions?

I am making a 2D graphics engine. I am new to JavaScript and have been developing this project. So far, create a background (a mosaic map made of smaller images in a grid) and sprites (a small image
with a higher z-index). I omitted my test code as I didn't mind it being revised, but if it needs to be included I can add it.

I am looking for best practice tips for javascript or in general. A specific question is: Are OLNs (sprites and tilemap) used correctly or should something else be used?

js:

'use strict';

const TILEMAPSIZE = 160; // Total number of tiles displayed. Must be a multiple of TILECOLUMNS.
const TILECOLUMNS = 16; // Number of columns

let tileSet = (); // Set of all tiles to be used
let tilemapList = (); // The order in which the tiles are used via references to elements in tileSet
let spriteSet = (); // Set of all sprites to be used

loadResources(); 

let sprites = (function (){
    function createSprites(spritesList) {
        let spriteCount = 0;
        spritesList.forEach(x => {
            let sprite = document.createElement('img');
            sprite.src = x;
            sprite.className = "sprites";
            sprite.id = "sprite" + spriteCount;
            sprite.style.visibility = "hidden";
            ++spriteCount;
            document.getElementById("window").appendChild(sprite);
        });
    }

    function show(index) {
        const spriteStyle = document.getElementById("sprite" + index).style
        spriteStyle.visibility = "visible";
    }

    function hide(index) {
        spriteStyle = document.getElementById("sprite" + index).style
        spriteStyle.visibility = "hidden";
    }

    function reflectY(spriteIndex) {
        const sprite = "sprite" + spriteIndex;
        const transform = document.getElementById(sprite).style.transform;
        if (transform === "scale(-1, 1)"){ 
            document.getElementById(sprite).style.transform = "scale(1)";
        }
        else if (transform === "scale(1, -1)"){
            document.getElementById(sprite).style.transform = "scale(-1)";
        }
        else if (transform === "scale(-1)"){
            document.getElementById(sprite).style.transform = "scale(1, -1)";
        }
        else {
            document.getElementById(sprite).style.transform = "scale(-1, 1)";
        }
    }

    function reflectX(spriteIndex) {
        const sprite = "sprite" + spriteIndex;
        const transform = document.getElementById(sprite).style.transform;
        if (transform === "scale(-1, 1)"){
            document.getElementById(sprite).style.transform = "scale(-1)";
        }
        else if (transform === "scale(1, -1)"){
            document.getElementById(sprite).style.transform = "scale(1)";
        }
        else if (transform === "scale(-1)"){
            document.getElementById(sprite).style.transform = "scale(-1, 1)";
        }
        else {
            document.getElementById(sprite).style.transform = "scale(1, -1)";
        }
    }

    function reflect(spriteIndex, dX, dY) {
        const sprite = "sprite" + spriteIndex;
        if (dX === true && dY === true){
            document.getElementById(sprite).style.transform = "scale(1)";
        }
        else if (dX === true && dY === false){
            document.getElementById(sprite).style.transform = "scale(1, -1)";
        }
        else if (dX === false && dY === true){
            document.getElementById(sprite).style.transform = "scale(-1, 1)";
        }
        else if (dX === false && dY === false){
            document.getElementById(sprite).style.transform = "scale(-1)";
        }
    }

    function translate(spriteIndex, dX, dY) {
        const sprite = "sprite" + spriteIndex;
        const posLeft = parseInt(document.getElementById(sprite).style.left.slice(0, -2)) + dX;
        const posTop = parseInt(document.getElementById(sprite).style.top.slice(0, -2)) + dY;
        document.getElementById(sprite).style.left = posLeft + "px";
        document.getElementById(sprite).style.top = posTop + "px";
    }

    function setPosition(spriteIndex, dX, dY) {
        const sprite = "sprite" + spriteIndex;
        document.getElementById(sprite).style.left = dX +"px";
        document.getElementById(sprite).style.top = dY + "px";
    }

    function getPosition(spriteIndex) {
        const sprite = "sprite" + spriteIndex;
        return {
            x: parseInt(document.getElementById(sprite).style.left.slice(0, -2)),
            y: parseInt(document.getElementById(sprite).style.top.slice(0, -2))
        };
    }

    function getOrientation(spriteIndex) {
        const sprite = "sprite" + spriteIndex;
        const transform = document.getElementById(sprite).style.transform;
        let pair = {};

        if (transform === "scale(1)"){
            pair = {x: 1, y: 1};
        }
        else if (transform === "scale(-1)"){
            pair = {x: -1, y: -1};
        }
        else if (transform === "scale(1, -1)"){
            pair = {x: 1, y: -1};
        }
        else if (transform === "scale(-1, 1)"){
            pair = {x: -1, y: 1};
        }
        else {
            pair = {x: 0, y: 0};
        }
        return pair;
    }

    return{
        setPosition: setPosition,
        getPosition: getPosition,
        getOrientation: getOrientation,
        translate: translate,
        reflect: reflect,
        reflectX: reflectX,
        reflectY: reflectY,
        createSprites: createSprites,
        show: show,
        hide: hide
    };
}())

let tilemap = (function (){
    function create(){
        // create the tile map
        for (let i = 0; i < TILEMAPSIZE; ++i){
            let tile = document.createElement('div');
            tile.className = "tile";
            tile.id = "tile" + i;
            document.getElementById("tilemap").appendChild(tile);
        };            
        // set the number of columns
        let value = "";
        for (let i = 0; i < TILECOLUMNS; ++i){
            value += "auto ";
        }
        document.getElementById("tilemap").style.gridTemplateColumns = value;
        // insert images
        let index = 0;
        tilemapList.forEach(x => {
            let img = document.createElement('img');
            img.src = x;
            img.className = "tileImage";
            document.getElementById("tile" + index).appendChild(img);
            ++index; 
        })
    }

    function show() {
        spriteStyle = document.getElementById("tilemap").style
        spriteStyle.visibility = "visible";
    }

    function hide() {
        spriteStyle = document.getElementById("tilemap").style
        spriteStyle.visibility = "hidden";
    }

    function translate(dX, dY) {
        const posLeft = parseInt(document.getElementById("viewport").style.left.slice(0, -2)) + dX;
        const posTop = parseInt(document.getElementById("viewport").style.top.slice(0, -2)) + dY;
        document.getElementById("viewport").style.left = posLeft + "px";
        document.getElementById("viewport").style.top = posTop + "px";
    }

    function setPosition(dX, dY) {
        document.getElementById("viewport").style.top = dY + "px";
        document.getElementById("viewport").style.left = dX + "px";
    }

    function getPosition() {
        return {
            x: parseInt(document.getElementById("viewport").style.left.slice(0, -2)),
            y: parseInt(document.getElementById("viewport").style.top.slice(0, -2))
        };
    }

    return{
        setPosition: setPosition,
        getPosition: getPosition,
        translate: translate,
        show: show,
        hide: hide,
        create: create};   
}())

tilemap.setPosition(0, 0);
tilemap.create();

sprites.createSprites(spriteSet);
sprites.setPosition(0, 235, 240);
sprites.show(0); 

function loadResources(){
    const img1 = 'https://georgec0stanza.github.io/2DgraphicsEngine/images/ferns.jpg';
    const img2 = 'https://georgec0stanza.github.io/2DgraphicsEngine/images/tulips.jpg';
    const img3 = 'https://georgec0stanza.github.io/2DgraphicsEngine/images/water.jpg';

    const sprite0 = 'https://georgec0stanza.github.io/2DgraphicsEngine/images/daffodil.jpg';    
    const sprite1 = 'https://georgec0stanza.github.io/2DgraphicsEngine/images/eagle.jpg';    

    spriteSet = (sprite0, sprite1);
    tileSet = (img1, img2, img3);
    tilemapList = (tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0), tileSet(0) , tileSet(2), tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) , tileSet(2), tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) ,tileSet(2), tileSet(1) , tileSet(1) , tileSet(0) , tileSet(2));    
}

html:




    
    
    Page title
    
    
    


    

css:

:root {
    --TILESIZE: 50px; /* Size of tiles */
    --SPRITESIZE: 50px; /* Size of sprites */
    --WINDOWIDTH: 650px;
    --WINDOWHEIGHT: 500px;
    --WINDOWBACKGROUND: white;
}

body {
    background-color: black;
}

img {
    display: block;
}

#window {
    overflow: hidden;
    margin: 0 auto;
    position: relative;
    width: var(--WINDOWIDTH);
    height: var(--WINDOWHEIGHT);
    background: var(--WINDOWBACKGROUND);
}

#viewport {
    position: absolute;
}

#tilemap {
  display: grid;
  z-index: -1;
}

.tile {
  text-align: center;
}

.tileImage {
    height: var(--TILESIZE);
    width:  var(--TILESIZE);
}

.sprites {
    position: absolute;
    height: var(--SPRITESIZE);
    width:  var(--SPRITESIZE);
    z-index: 1;
    transform: scale(1);
}
```

java – Does my code follow good clean code conventions?

Here is a class that I have implemented to sort parameter rows in the form of an array of strings.

public class ParameterLinesSorter : IParameterLinesSorter
{
    private int identiferIndex;
    private IEnumerable parameterLines;

    public IEnumerable> Sort(IEnumerable parameterLines, int identiferIndex)
    {
        this.identiferIndex = identiferIndex;
        this.parameterLines = parameterLines;

        return IsNotNullAndNotEmpty() ? FilterAndSort() : new List>();
    }

    private bool IsNotNullAndNotEmpty()
    {
        return parameterLines != null && parameterLines.Any();
    }

    private IEnumerable> FilterAndSort()
    {
        return parameterLines
            .Where(parameterLine => parameterLine.Any())
            .GroupBy(parameterLine => parameterLine.ElementAt(identiferIndex));
    }
}

Here is an example of usage using a simple test:

    (Test)
    public void ShouldReturnListWithTwoGroupsOfOneElement()
    {
        IEnumerable parameterLines = new List() {
            new string(){ "C", "3", "3" },
            new string(){ "M", "3", "5" }
        };


        IEnumerable> expectedGroups = new List>() {
            new List(){ new string(){ "C", "3", "3" }},
            new List(){ new string(){ "M", "3", "5" }}
        };

        Assert.AreEqual(expectedGroups, sorter.Sort(parameterLines, 0));
    }

Please note that this class and the Sort method will be used only once in the entire system.

Just before, the IsNotNullAndNotEmpty and FilterAndSort methods had arguments, but I read that the best for a method was to have no arguments. Therefore, I preferred to pass identifierIndex and parameterLines as instance variables. Is it really a good practice?

I am listening to any other recommendations.

Thanks in advance.