アプリ関連ニュース
- 2020年10月02日
- VR
Oculus Quest 2 続報
先日のFacebook Connectで発表のあった「Oculus Quest 2」ですが、そのスペックと戦略的な価格設定から発売前からとても話題になっています。
VR系の製品紹介やゲーム実況などをおこなっている何人かのYouTuberのもとには、発売前の「Oculus Quest 2」の実機が先行して届けられているようで、「Oculus Quest 2」の開封動画や製品紹介、比較動画などが、アップロードされはじめています。
今回はそれらの動画やレビューを視聴しての感想をかきたいと思います。
nishida at 2020年10月02日 10:00:12
- 2020年9月28日
- 技術情報
Builder Design Pattern
Builder is a creational design pattern that allows you to build complex objects step by step. The pattern allows you to produce different types and representations of an object using the same building code.
The Builder pattern suggests that you extract the building code from the object of its own class and move it to separate objects called constructors.
To create an object, run a series of these steps on a constructor object. The important part is that you don’t need to call all the steps. You can call only the steps necessary to produce a particular configuration of an object.
Check out the sample codes below.
PHP sample code
<?php
/**
* Builder interface with different methods.
*/
interface Builder
{
public function addVege();
public function addNoodle();
public function addMeat();
}
/**
* Implementing the builder and interface with different implementations
*/
class MalaBuilder implements Builder
{
private $product;
/**
* To rest the Mala Object as a new one.
*/
public function __construct()
{
$this->product = new Mala;
}
/**
* All production steps work with the same product instance.
*/
public function addVege()
{
$this->product->ingredients[] = "Vegetable";
}
public function addNoodle()
{
$this->product->ingredients[] = "Noodle";
}
public function addMeat()
{
$this->product->ingredients[] = "Meat";
}
/**
* returning results for each different implementatins.
*/
public function add()
{
$result = $this->product;
/**
* To rest the Mala Object as a new one.
*/
$this->product = new Mala;
return $result;
}
}
/**
* display the final results of Malabuilder
*/
class Mala
{
public $ingredients = [];
public function returnMala()
{
echo implode(', ', $this->ingredients) . "<br>";
}
}
/**
* I added a sample MalaDirector to create a few ready made implementations.
*/
class MalaDirector
{
private $builder;
public function setBuilder(Builder $builder)
{
$this->builder = $builder;
}
public function addVegeNoodle()
{
$this->builder->addVege();
$this->builder->addNoodle();
}
public function addVegeMeatNoodle()
{
$this->builder->addVege();
$this->builder->addNoodle();
$this->builder->addMeat();
}
}
function clientCode(MalaDirector $malaDirector)
{
$builder = new MalaBuilder;
$malaDirector->setBuilder($builder);
echo "This is vege Mala:\n";
$malaDirector->addVegeNoodle();
$builder->add()->returnMala();
echo "Full Ingredients Mala:\n";
$malaDirector->addVegeMeatNoodle();
$builder->add()->returnMala();
// This time with no MalaDirector usage.
echo "Custom Mala:\n";
$builder->addNoodle();
$builder->addMeat();
$builder->add()->returnMala();
}
$malaDirector = new MalaDirector;
clientCode($malaDirector);
C# sample code
using System;
using System.Collections.Generic;
namespace HelloWorld
{
/**
* Builder interface with different methods.
*/
public interface Builder
{
void addVege();
void addNoodle();
void addMeat();
}
/**
* Implementing the builder and interface with different implementations
*/
public class MalaBuilder : Builder
{
private Mala _mala = new Mala();
/**
* To rest the Mala Object as a new one.
*/
public MalaBuilder()
{
this._mala = new Mala();
}
public void addVege()
{
this._mala.Add("vegetable");
}
public void addNoodle()
{
this._mala.Add("noodle");
}
public void addMeat()
{
this._mala.Add("meat");
}
/**
* returning results for each different implementatins.
*/
public Mala FinalMala()
{
Mala result = this._mala;
this._mala = new Mala();
return result;
}
}
/**
* add function to the list object of ingredients.
* return the final results of Malabuilder.
*/
public class Mala
{
private List<object> incredigents = new List<object>();
public void Add(string part)
{
this.incredigents.Add(part);
}
public string ReturnMala()
{
string str = string.Empty;
for (int i = 0; i < this.incredigents.Count; i++)
{
str += this.incredigents[i] + ", ";
}
str = str.Remove(str.Length - 2); //removing last comma and space.
return + str + "\n";
}
}
/**
* A sample MalaDirector to create a few ready made implementations.
*/
public class Director
{
private Builder _builder;
public Builder Builder
{
set { _builder = value; }
}
public void addVegeNoodle()
{
this._builder.addVege();
}
public void addVegeMeatNoodle()
{
this._builder.addVege();
this._builder.addNoodle();
this._builder.addMeat();
}
}
class Program
{
static void Main(string[] args)
{
var director = new Director();
var builder = new MalaBuilder();
director.Builder = builder;
Console.WriteLine("Vegetable Mala:");
director.addVegeNoodle();
Console.WriteLine(builder.FinalMala().ReturnMala());
Console.WriteLine("Full Ingredients Mala:");
director.addVegeMeatNoodle();
Console.WriteLine(builder.FinalMala().ReturnMala());
// This time with no MalaDirector usage.
Console.WriteLine("Custom Mala:");
builder.addNoodle();
builder.addMeat();
Console.Write(builder.FinalMala().ReturnMala());
}
}
}
By Yuuma
yuuma at 2020年09月28日 11:00:41
- 2020年9月25日
- 技術情報
[Laravel] Passportを使用したBearer token認証[2]
PHPのLaravelフレームワークのPassportを使用したBearer token認証の方法について紹介いたします。本記事は前回の「[Laravel] Passportを使用したBearer token認証[1]」の続きとなります。今回はPassportのインストール方法からLaravel標準の認証機能をPassportに変更するところまでを説明します。
続きを読むnishida at 2020年09月25日 10:00:37
- 2020年9月21日
- 技術情報
Laravel Livewire
I am talking about the brief introduction about laravel livewire today.
Its aim is to provide a modern and dynamic web experience without having to waste time with reactive web frameworks or Javascript at all.
And for the most part: it can. Livewire really works, and in the next few years we will almost definitely see some big, serious projects on it.
When you activate the livewire, you will
– Write a PHP class, which will act as the backend part of a frontend component. Public fields will be visible to Livewire.
– Write an interface component in the Laravel (Blade) template language. This component refers to the fields in the backend component that you wrote earlier.
– Write methods in your backend component class that change the state of public fields.
– Create an instance of the component in another view or another component.
– When you visit the page, Livewire will render the initial state of the component as HTML and inject it into the page you see. Livewire will have already attached auto-generated JavaScript events to the page, which call the methods you wrote in step 3 above.
– When you take action, the Javascript events that Livewire generates will make an AJAX request to the Livewire endpoint on the backend. This will call the method you wrote, changing the public properties you defined.
-Your backend component’s render method is then called, which produces a snippet of HTML. This HTML snippet is the response to the AJAX request.
– Finally, the client-side Livewire component hot-patches this HTML on the page.
Further more you can look up the livewire lifecycle hooks more details here.
https://laravel-livewire.com/docs/2.x/lifecycle-hooks
Livewire has lots of interesting features but it still have some drawbacks as follow.
– Livewire violates the separation of concerns
– Livewire violates the single-responsibility principle
– Livewire complicates the development workflow
– Too Many AJAX Requests
– Livewire is difficult to test
And Finally maintainability would be harder as the application grows.
yuuma at 2020年09月21日 11:00:43
- 2020年9月18日
- VR
Facebook「Oculus Quest 2」を発表
2020年9月16日に開催されたFacebook Connect 7で、新型VRヘッドセット「Oculus Quest 2」が発表されました。これは現行製品の「Oculus Quest」の後継となるPC不要のスタンドアロン一体型VRヘッドセットです。
続きを読むnishida at 2020年09月18日 10:00:14