アプリ関連ニュース
- 2020年11月30日
- 技術情報
Dependency Injection in PHP
Dependency injection is the process by which one object provides the dependencies of another object. Dependency injection is a software design approach that avoids hard-coded dependencies and allows you to change dependencies at runtime and compile time.
Lets take a look along with the examples. Lets say we have a Food class that will supply dependency to Dinner Class.
<?php
class Food
{
protected $food;
public function __construct($food)
{
$this->food = $food;
}
public function get()
{
return $this->food;
}
}
After that, lets create a dinner class without dependency injection first.
<?php
class Dinner
{
public function eat()
{
$food = new Food("Chicken soup");
return $food->get();
}
}
$dinner = new Dinner();
echo $dinner->eat(); //output - Chicken soup
In the above style of Dinner class, we have hardcoded food class that is bad in coupling and not well dependency injected. Lets fix our dinner class using dependency injection.
<?php
class Dinner
{
protected $dinner;
//receiving the dependency object food.
public function __construct(Food $food)
{
$this->dinner = $food;
}
public function eat()
{
return $this->dinner->get();
}
}
$food = new Food("Chicken soup");
//supplying the food object.
$dinner = new Dinner($food);
echo $dinner->eat(); //output - Chicken soup
Now, we have added a constructor to be injected the necessary food dependency object. The code is now loosely coupled and not hardcoded in dinner class anymore.
By Yuuma.
yuuma at 2020年11月30日 11:00:23
- 2020年11月27日
- 技術情報
[Laravel] Eloquentとページネーション(3)
自力でページネーションの実装をおこなうには、大変工数がかかりますが、Laravelフレームワークが用意しているページネーションを使用することで工数が大幅に軽減できます。
今回はLaravelフレームワークのページネーションの実装方法を紹介したいと思います。本記事は前回の「[Laravel] Eloquentとページネーション(2)」の続きになります。
nishida at 2020年11月27日 10:00:32
- 2020年11月25日
- AI
GoogleのAIを使って怪物を描けるキメラペインター
tanaka at 2020年11月25日 10:00:10
- 2020年11月23日
- Apple
Apple MacBook Pro 13-Inch (M1, Late 2020)

Apple has released new macbook models with their own chips in late 2020 & 13inch is one of my favourites. It’s suitable for multimedia editors, software developers, and other creative professionals, and its also appealing to mainstream Mac users seeking higher performance than the MacBook Air in a laptop that’s smaller and less expensive than the flagship 16-inch MacBook Pro. The latest 13-inch MacBook Pro reviewed here is as sleek as ever and more powerful than before, thanks to Apple’s new M1 processor. Someone who wants a well performance and smaller one, this 13inch MacBook Pro will probably the best suit right now.
Here is what I am thinking about pros and cons.
PROS
- Long battery life (I like this one most)
- Speedy performance from Apple M1 chip
- Brilliant Retina display
- Excellent build quality
- Comfortable keyboard and trackpad
- Improved webcam
CONS
- Only two USB-C ports
- Stingy starting standard 256GB SSD, 8GB RAM
- Still No touch screen
By Yuuma
yuuma at 2020年11月23日 11:00:56
- 2020年11月20日
- Unity
Unity 2019.4.14(LTS)でStandard Assetsを使用する
nishida at 2020年11月20日 10:00:21