Skip to content

Instantly share code, notes, and snippets.

@onionmk2
onionmk2 / 1_srp.md
Created February 20, 2025 02:26 — forked from matarillo/1_srp.md
SOLID原則はソリッドではない

SOLIDはソリッドではない - 単一責任原則を検証する

https://naildrivin5.com/blog/2019/11/11/solid-is-not-solid-rexamining-the-single-responsibility-principle.html

2019年11月11日

最近、SOLIDの原則について考えていて、その有用性に疑問を感じている。 SOLIDの原則は曖昧で、範囲が広すぎて、混乱を招き、場合によっては完全に間違っている。しかし、これらの原則の動機は正しい。問題は、ニュアンスの異なる概念を簡潔な文に落とし込もうとすることにあって、翻訳の過程で価値の大部分を失っているのだ。 これはプログラマーを間違った道へと導いてしまう(私にとっては確かにそうだった)。

おさらいとして、SOLIDの原則は以下の通りである:

@onionmk2
onionmk2 / DiscoverBlueprintComments.cpp
Created June 12, 2024 03:16 — forked from rdeioris/DiscoverBlueprintComments.cpp
How to extract Unreal Engine Blueprint comments via c++
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
TArray<FAssetData> AssetData;
AssetRegistryModule.Get().GetAssetsByClass(UBlueprint::StaticClass()->GetFName(), AssetData, true);
for (FAssetData& Asset : AssetData)
{
if (Asset.ObjectPath.ToString().StartsWith("/Game/"))
@onionmk2
onionmk2 / get_global_id.cu
Last active January 5, 2018 02:12 — forked from athiakos/cuda cheat sheet
cuda のid計算がよくわからないので、まとめてみる。
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
namespace comment_thread_id
{
/*
blockIdx.x == n
blockIdx.y == 1
blockIdx.z == 1
@onionmk2
onionmk2 / gist:a2c26752975a2509dc69cf564f87e709
Created April 3, 2017 23:43 — forked from LearnCocos2D/gist:77f0ced228292676689f
Overview of Entity Component System (ECS) variations with pseudo-code

For background and further references see: Entity Component Systems on Wikipedia

ECS by Scott Bilas (GDC 2002)

Entity->Components->Update
  • entity = class: no logic + no data OR at most small set of frequently used data (ie position)
  • component = class: logic + data
foreach entity in allEntities do
    foreach component in entity.components do
@onionmk2
onionmk2 / gist:97a593048f4efe1fcd48e3760bb7b73e
Created February 16, 2017 11:52 — forked from tany3/gist:2d032cbbbd9db04b976d
重複処理 IEnumerableをそのまま使い回さない - Possible multiple enumeration of IEnumerable

IEnumerableをそのまま使うと、使う度に毎回変換される。遅延実行。 http://confluence.jetbrains.com/display/ReSharper/Possible+multiple+enumeration+of+IEnumerable

Assuming that GetNames() returns an IEnumerable, we are, effectively, doing extra work by enumerating this collection twice in the two foreach statements. If GetNames() results in a database query, you end up doing that query twice, while both times getting the same data.

ということで、特に複数回使う場合など適宜ToList()やToArray()しておく。

参考:LINQ クエリの概要 (C#) http://msdn.microsoft.com/ja-jp/library/bb397906.aspx

@onionmk2
onionmk2 / Singletons.md
Created February 5, 2017 10:34 — forked from Ashwinning/Singletons.md
A copy of the post on Singletons in Unity/C# as it appeared on UnityPatterns.com

Singletons

Original post by David Laskey on UnityPatterns

As you develop in Unity, you’ll often find that it’s handy to have just single instances of certain objects. For example, let’s say we have a single GameObject, “MusicManager”, that’s in charge of our music. It might look like this:

using UnityEngine;