7
Presentation:
I created a photo.Cs class that should be responsible for:
- Calculate the angle of view of the lens;
- Receive lens zoom (in mm)
- Receive the cut factor (value multiplied by the lens zoom shows the actual lens value)
- Dimensions of the camera sensor, etc.
I thought about creating the interface, more for academic purposes than practical.
Interface
namespace fotografia
{
    public enum _CamerasFabricante { Canon=0, Nikon = 1, Sony = 2 };
    public interface IFotografia
    {
        int CameraFabricante(_CamerasFabricante _value);
        double FatordeCorte { get; set; }
        int ObjetivaMM { get; set; }
        double SensorHmm { get; set; }
        double SensorVmm { get; set; }
        double CalculoAnguloVisaoH();
        double CalculoAnguloVisaoV();
    }
}
so I created the class for this interface:
using System;
namespace fotografia
{
    internal class fotografia : IFotografia
    {
        public double FatordeCorte { get; set; }
        public int ObjetivaMM { get; set; }
        public int CameraFabricante(_CamerasFabricante _value)
        {
            return (int)_value;
        }
        private double _MMFinalObjetiva()
        {
            return (Convert.ToDouble(ObjetivaMM) * FatordeCorte);
        }
        public double SensorHmm
        {
            get;
            set;
        }
        private double myVar;
        public double SensorVmm
        {
            get { return myVar; }
            set { myVar = value; }
        }
        public double CalculoAnguloVisaoH()
        {
            double fov = SensorHmm / (2 * _MMFinalObjetiva());
            double arctan = 2 * Math.Atan(fov)  * 180.0 / Math.PI;
            return arctan;
        }
        private double CalculoAnguloVisaoV()
        {
            double fov = SensorVmm / (2 * _MMFinalObjetiva());
            double arctan = 2 * Math.Atan(fov) * 180.0 / Math.PI;
            return arctan;
        }
    }
}
Doubts:
- Is this class doing more than it should? because each method really does only 1 thing, but the photography class does everything in relation to photography. On the sole responsibility this correct?
- I implemented the Interface and the class correctly?
I’m calling it that on the show
IFotografia ft = new fotografia();
            ft.CameraFabricante(_CamerasFabricante.Canon);
            ft.ObjetivaMM = 50;
            ft.SensorHmm = 22.3;
            ft.FatordeCorte = 1.6;
            var t = ft.CalculoAnguloVisaoH();
Relevant: http://qualityisspeed.blogspot.com.br/2014/08/why-i-dont-teach-solid.html
– Maniero