アプリ関連ニュース
- 2020年10月09日
- 技術情報
[Laravel] Passportを使用したBearer token認証[3]
PHPのLaravelフレームワークのPassportを使用したBearer token認証の方法について紹介します。
本記事は前回の「[Laravel] Passportを使用したBearer token認証[2]]」の続きとなります。
今回は認証テスト用ユーザーの追加をおこない、Bearer tokenの発行と認証について説明します。
nishida at 2020年10月09日 10:00:28
- 2020年10月07日
- 他の話題
各社のクラウドゲームプラットフォームサービスについて
各社のクラウドゲームプラットフォームサービスについて
前回、nvidiaのGeforce Nowを記事にとりあげました。
この他に
昨年からサービスを開始しているGoogleのStadiaや
先月からサービスを開始しているMicrosoftのxCloudが
あります。(どちらも現在日本でのサービスは提供されていません)
xCloudは現行のXbox Game Pass Ultimateに加入していれば
追加料金無しでサービスを利用できるようです。
日本国内で同サービスを利用できるようになるのは
2021年上半期とアナウンスされています。
Xbox Game Pass 対象のゲームが追加料金なしで
プレイすることができるなら大きなアドバンテージですね。
また、Amazonもクラウドゲームサービスの
Lunaというサービスを招待制のEarly Accessとして
提供しているようです。
StadiaはYoutube
xCloudはFacebook Gaming
LunaはTwitch
と、ライブ動画配信サービスとの連携を行い
ライブ配信から気になったゲームを起動できるような計画を
各社行っているようです。
高速、低遅延を謳う5Gモバイルネットワーク
が普及すれば、デバイス問わずコンシューマ機や
PCと同レベルのゲーム体験が行えるかもしれませんね。
(プレイ中はHD解像度以上の動画を再生し続けるような状態
なので、通信容量をすぐに使い果たしてしまいそうですが。)
水曜担当:Tanaka
tanaka at 2020年10月07日 10:00:39
- 2020年10月05日
- 技術情報
Prototype Design Pattern
Prototype is a build design pattern that allows you to copy existing objects without making your code dependent on their classes.
Declare an abstract base class that specifies a pure virtual “clone” method, and maintain a dictionary of all concrete “cloneable” derived classes. Any class that needs a “polymorphic constructor” capability: It derives from the abstract base class, registers its prototypical instance, and implements the clone () operation.
So the client, instead of writing code that invokes the “new” operator on a wired class name, calls a “clone” operation on the abstract base class, supplying an enumerated string or data type that designates the class desired derivative.
Lets see PHP & C# code samples as below.
PHP
<?php
// I made a common prototype interface for cloning purpose.
// has a single function called _clone
abstract class Person {
protected $name;
abstract function __clone();
function getName() {
return $this->name;
}
function setName($name) {
$this->name = $name;
}
}
// Here is a concrete class extending the person prototype.
// we will implement the _clone method to support object cloning.
//This may contain a lot of fields and implementations but I will keep this simple for now.
class Boy extends Person {
function __clone() {
}
}
//here is our first time instantiation of boy concrete class
$person = new Boy();
//next time we will clone that object by using clone.
// we will also pass the name param dynamically.
// clone1
$person1 = clone $person;
$person1->setName('Hlaing');
$person1->getName();
// clone2
$person2 = clone $boy;
$person2->setName('Tin');
$person2->getName();
print_r($person1);
print_r($person2);
?>
C#
using System;
using System.Collections.Generic;
namespace HelloWorld
{
// Here is my simple object that support object cloning.
// I already build a function called copyclone to clone this object.
public class Person
{
public string Name;
public Person CopyClone()
{
return (Person)this.MemberwiseClone();
}
}
class Program
{
static void Main(string[] args)
{
// firstly we build a object using new instantiation
Person person = new Person();
//next time we will clone that object by theh function copyclone.
// we will also pass the name param dynamically.
// clone1
Person person1 = person.CopyClone();
person1.Name = "Hlaing";
// clone2
Person person2 = person.CopyClone();
person2.Name = "Tin";
Console.WriteLine(person1.Name);
Console.WriteLine(person2.Name);
}
}
}
By Yuuma.
yuuma at 2020年10月05日 11:00:21
- 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