2019年11月11日
最近、SOLIDの原則について考えていて、その有用性に疑問を感じている。 SOLIDの原則は曖昧で、範囲が広すぎて、混乱を招き、場合によっては完全に間違っている。しかし、これらの原則の動機は正しい。問題は、ニュアンスの異なる概念を簡潔な文に落とし込もうとすることにあって、翻訳の過程で価値の大部分を失っているのだ。 これはプログラマーを間違った道へと導いてしまう(私にとっては確かにそうだった)。
おさらいとして、SOLIDの原則は以下の通りである:
2019年11月11日
最近、SOLIDの原則について考えていて、その有用性に疑問を感じている。 SOLIDの原則は曖昧で、範囲が広すぎて、混乱を招き、場合によっては完全に間違っている。しかし、これらの原則の動機は正しい。問題は、ニュアンスの異なる概念を簡潔な文に落とし込もうとすることにあって、翻訳の過程で価値の大部分を失っているのだ。 これはプログラマーを間違った道へと導いてしまう(私にとっては確かにそうだった)。
おさらいとして、SOLIDの原則は以下の通りである:
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/")) |
#include <cuda_runtime.h> | |
#include <device_launch_parameters.h> | |
namespace comment_thread_id | |
{ | |
/* | |
blockIdx.x == n | |
blockIdx.y == 1 | |
blockIdx.z == 1 | |
For background and further references see: Entity Component Systems on Wikipedia
entity
= class: no logic + no data OR at most small set of frequently used data (ie position)component
= class: logic + dataforeach entity in allEntities do
foreach component in entity.components do
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
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;