All Projects β†’ al3rez β†’ gigsib

al3rez / gigsib

Licence: other
πŸ“‘Golang Is Good, Structure Is Bad

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to gigsib

VF-BlenderAutoSaveRender
Automatically saves a numbered or dated image after every render and can extend the Blender output path with dynamic variables
Stars: ✭ 34 (+88.89%)
Mutual labels:  naming-conventions
Version3
Version 3 of Chem4Word - A Chemistry Add-In for Microsoft Word
Stars: ✭ 53 (+194.44%)
Mutual labels:  structure
clean-architecture
Recommendations for sufficiently clean architecture for local database storage and persistent storage.
Stars: ✭ 11 (-38.89%)
Mutual labels:  structure
styleguide
Official code style guide of Banksalad
Stars: ✭ 91 (+405.56%)
Mutual labels:  naming-conventions
Project-Template
A template for modern C++ projects with useful features for developing cross-platform products.
Stars: ✭ 44 (+144.44%)
Mutual labels:  structure
fsify
Convert an array of objects into a persistent or temporary directory structure.
Stars: ✭ 24 (+33.33%)
Mutual labels:  structure
project-structure-sample
Shows how to keep front end and back end separated
Stars: ✭ 91 (+405.56%)
Mutual labels:  structure
python
Python Style Guide
Stars: ✭ 49 (+172.22%)
Mutual labels:  naming-conventions
abbreviations-in-code
List of common abbreviation in program codes
Stars: ✭ 163 (+805.56%)
Mutual labels:  naming-conventions
laravel5Angular4
Laravel 5.4 & Angular 4.3.4
Stars: ✭ 37 (+105.56%)
Mutual labels:  structure
binstruct
Golang binary decoder for mapping data into the structure
Stars: ✭ 67 (+272.22%)
Mutual labels:  structure
StructureBlockLib
StructureBlockLib is a bukkit implementation for handling structures on spigot server.
Stars: ✭ 46 (+155.56%)
Mutual labels:  structure
jsberry
JSBerry is open source modular simple architecture for building Node.js applications.
Stars: ✭ 85 (+372.22%)
Mutual labels:  structure
Algorithm
Record daily training algorithms and data structures by Swift
Stars: ✭ 12 (-33.33%)
Mutual labels:  structure
Database-Naming-Convention
Database Naming Conventions & Best Practices
Stars: ✭ 76 (+322.22%)
Mutual labels:  naming-conventions
PBxplore
A suite of tools to explore protein structures with Protein Blocks 🐍
Stars: ✭ 21 (+16.67%)
Mutual labels:  structure
Leetcoding-Challenge
This repository contains Leetcode Challenge Submissions.
Stars: ✭ 26 (+44.44%)
Mutual labels:  structure
CSharpHandbook
The focus of this document is on providing a reference for writing C#. It includes naming, structural and formatting conventions as well as best practices for writing clean, safe and maintainable code. Many of the best practices and conventions apply equally well to other languages.
Stars: ✭ 25 (+38.89%)
Mutual labels:  naming-conventions
MatrixLib
Lightweight header-only matrix library (C++) for numerical optimization and machine learning. Contact me if there is an exciting opportunity.
Stars: ✭ 35 (+94.44%)
Mutual labels:  structure
Apex-Code-Conventions
Apex conventions and best practices for Salesforce Developers
Stars: ✭ 28 (+55.56%)
Mutual labels:  naming-conventions

Golang Is Good, Structure Is Bad

I begin with imports. Nomarlly you just import a package and the last element of the package path would be the package you want to use.

import "foo/bar/baz"

Problem

So what if there's (probably is) type called Baz and you use it:

import "foo/bar/baz"

func main() {
        baz := baz.New()
}

wat.

You just shadowed the package name with calling a variable baz and you writing baz twice baz.Baz in linguistics terms which is not good (remember DRY!) and probably you'd write a factory function called NewBaz that's even worse.

package baz

type Baz struct{}

func NewBaz() {
        // do something
}

Solution

I found a solution or trick to naming things in decent way IMO. So you just name your package whatever you want and there must be only one exported type inside the package and you should call it Type and you must separate each type into different packages and you must name packages explicitly with in PascalCase.

import Baz "foo/bar/baz"

var baz Baz.Type{}

Why?

With that trick I can use packages as metaphor to classes and you can write:

package main

import Basket "gigsib/model/basket"
import BasketItem "gigsib/model/basket_item"

func main() {
        basket := Basket.New(nil)
        basket.AddItemBang(BasketItem.New("NikeLab ACG 07 KMTR", "1100"))
        basket.AddItemBang(BasketItem.New("Nike Kobe A.D. Triple Black", "750"))
        basket.TotalPrice()
}
    require "gigsib/model/basket"
    require "gigsib/model/basket_item"

    basket = Basket.new(nil)
    basket.add_item!(BasketItem.new("NikeLab ACG 07 KMTR", "1100"))
    basket.add_item!(BasketItem.new("Nike Kobe A.D. Triple Black", "750"))
    basket.total_price()

Do you see a big difference between ruby and golang? (expect ! and naming convention and entrypoint)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].