Code Monkey home page Code Monkey logo

otriples.portal's People

Contributors

appsolab avatar brianlparker avatar deepshri7 avatar evannlim avatar hassanhabib avatar kfitz114 avatar mehdi-aghaei avatar mtoncic avatar rcruzfreelance avatar shrihumrudha avatar stasnowak avatar talatmorshedtanbir avatar ysnarafat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

otriples.portal's Issues

CODE RUB: Some thoughts from watching https://www.youtube.com/watch?v=5Htj8JFglb4

Interesting Hassan.

Whilst following your guide video I couldn't see what ApiBroker did beyond providing some sort of wrapper around a HttpClient instance. My initial thoughts were ... could he not just use HttpClient directly?

That got me thinking, most API's (like mine) are built to a standard like OData so some common extensions might be all that's needed, or did I miss something?

I would do something like this ...

public static class HttpClientExtensions
{
       ILogger log; 
       
       static HttpClientExtensions(ILogger log) => this.log = log;

        public static async Task<Token> Authenticate(this HttpClient client, string user, string pass)
        {
            try
            {
                var auth = new { User = user, Pass = pass };
                var payload = new StringContent(auth.ToJsonForOdata(), Encoding.UTF8, "application/json");
                var response = await client.PostAsync("Account/Login", payload);
                response.EnsureSuccessStatusCode();
                var token = await response.Content.ReadAsAsync<Token>();
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", token.Id);
                return token;
            }
            catch { /* if we get here the server returned a json repsonse but it wasn't a token, it was more than likely an auth failure. */ }

            log.Warn("Auth request Failed for user " + user);
            return null;
        }

        public static Task<ODataCollection<T>> GetODataCollection(this HttpClient client, string query)
             => client.GetAsync(query)
                .ContinueWith(async t => await t.Result.Content.ReadAsAsync<ODataCollection<T>>())
                .Unwrap();
}

Then in my "broker consuming" code ...

var api = new HttpClient("base url");
await api.Authenticate("user", "pass");
var someFoos = (await api.GetODataCollection<Foo>("Foo?filter= ...")).ToArray();

Unless there's some function beyond this wrapper function for Brokers you could remove that layer altogether.
I did then noticed that you built a "LoggingBroker", would inject as a dependency an Ilogger instance through the usual mechanisms and if need be build my own ILogger structure that uses a http client within it as logging is something that happens literally everywhere in an application.

DISCUSSION: Dependency Inversion Principle Violation

Hi all,

Abstractions should not depend on details.
Here we're violating this by using the concrete implementation of the collection interface.
If in the concrete implementations we change List to something else that implements the same interface our contract would need to change. So we are strongly coupled.

For instance:

 public partial interface IApiBroker
 {
     ValueTask<List<Teacher>> GetAllTeachersAsync();
 }
 
 public interface ITeacherService
 {
     ValueTask<List<Teacher>> RetrieveAllTeachersAsync();
 }

Instead we should move to the abstraction and in the underlying implementations, if we need some concrete implementation, we can use it.
One reasonable choice would be IEnumerable. That's okay.

But, on the other side I believe that the data that we consume from other services/APIs should not be changeable.
Therefore we could use IReadOnlyCollection and enforce that collections are not changed.

I know that we can again change the underlying props of the collection objects but that's a different story.

What's your opinion on this?

PROVISION: Initialize Azure Resources for Blazor Project

Complete structure according to Standard Separation

I am very interested in OtripleS project and clean architecture standard which you have exaplained but only have one question Why OtripleS Project dosn’t include all layers according to standard like domain , application , infrastructure and UI to have complete structure according to standard clean architecture.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.