Determining response codes from void functions OOP

I am trying to create a Put endpoint using rest. Let’s say that under the link

/addresses/12345 

I am trying to add a new address (if that id doesn’t exist) or I’m trying to update it if it does already exist.

My application has several layers Controllers, Services, Models and Repositories. Given the fact that the business layer decides if an update or an add is required (this logic takes place in the service layer and below), how would the controllers be able to find out if an update or an add happened and return the correct status codes (201 for resource created, 204 if just an update has occured)?

My only ideas are to return some sort of result object, but that doesn’t feel particularly correct. For the cases where the service methods are not void, they usually return DTOs.

whats this codes means ( for encrypt datas )

1 SecretKeySpec(d9f52f6d-5168-4e5c-b7e6-57d6b57bac683f7315e7854047f5bed41a3f2f5a38a2,HmacSHA256) , Cipher[AES/CBC/PKCS5Padding] [PBEKeySpec] – Password: d9f52f6d-5168-4e5c-b7e6-57d6b57bac68 || Salt: 166:62:2.0.3

2 IV: 3f7315e7854047f5 (9HaB0schKRqnnO6iQQc85+P6KAKZ+omsLlDBW/9BLB0Vmb8VMO3AYtKh+RyxORTv , 967219be2a9048c8abf0f50a8e7b4364)

3 [PBEKeySpec] – Password: d9f52f6d-5168-4e5c-b7e6-57d6b57bac68967219be2a9048c8abf0f50a8e7b4364 || Salt: 166:62:2.0.3

4 IV: 3f7315e7854047f5 (fifyusiih@gmail.com , jBdL3XPKOl9pQPF/cI7NUGFBxD6N5nnSBFuGoC4R690=)

5 [PBEKeySpec] – Password: d9f52f6d-5168-4e5c-b7e6-57d6b57bac68967219be2a9048c8abf0f50a8e7b4364 || Salt: 166:62:2.0.3

6 IV: 3f7315e7854047f5 (hivhigf , NKB62GnZ5zugT+ArL/QQEg==)

Are Huffman codes self-synchronizing?

A code is (statistically) self-synchronizing if, given that the transmitted string is long enough, the receiver is guaranteed to eventually synchronize with the sender, even if bit flips or slips have occurred.

Do Huffman codes have this property in general? In case not, is there a criterion for testing if a Huffman code is self-synchronizing or, equivalently, is there a modified construction of a Huffman code which guarantees self-synchronization?

Huffman encoding with several codes already assigned

The classic Huffman algorithm, as Wikipedia states, finds an optimal prefix-free binary code with minimum expected codewords length, given a set of symbols and their weights. Now, suppose codewords for some (but not all) symbols are already assigned (maybe in a suboptimal way). How should we assign remaining codewords to the remaining symbols so as to minimize the minimum expected codewords length, assuming that there exists at least one binary sequence such that none existing codewords have it as their prefix, and neither of the existing codewords is its prefix?

I wonder if there’s a known solution to this problem. Yet I have been trying to develop an own one borrowing ideas from this proof.

Loja que se integre com api via link (API Xtream Codes)

Olá, já testei os mais populares softwares de lojas mas não achei nenhum que faça a integração que eu quero facilmente!

O que preciso é o seguinte, uma loja que possa vender tanto produtos físicos como virtuais, no caso o virtual seria creditos iptv que quero que sejam adicionados automaticamente via API (Esse código sei fazer) quando o pagamento for confirmado…

Só preciso que após o pagamento a loja envie uma requisição até o meu painel que vai gerar esses créditos ao usuário informado durante a compra!

Messages with status codes

I need to refactor following class:

public class Message {     public Guid ID { get; set; }     public string MessageIn { get; set; }     public string MessageOut { get; set; }     public int StatusCode { get; set; } //EDIT could be changed during message lifecycle      public bool IsDeletable     {         get         {             switch (this.StatusCode)             {                 case 12:                 case 13:                 case 22:                 case 120:                     return true;                 default:                     return false;             }         }     }      public bool IsEditable     {         get         {             switch (this.StatusCode)             {                 case 12:                 case 13:                 case 22:                 case 120:                     return true;                 default:                     return false;             }         }     }      public string Message     {         get         {             switch (this.StatusCode)             {                 case 11:                 case 110:                     return this.MessageIn;                 case 12:                 case 13:                 case 22:                 case 120:                     return this.MessageOut;                 default:                     return string.Empty;             }         }     } } 
  1. I would like to remove the business rules IsDeletable and IsEditable
  2. I would like to remove these switch statements at the same time

I am not sure if it’s worth knowing that I am mapping entity to database table through Entity Framework.

One more problem that I have is that fields MessageIn and MessageOut are dependent on StatusCode. One of them are always populated. I could create new property but still the switch case is there:

public string Message {     get     {         switch (this.StatusCode)         {             case 10:             case 12:             case 13:             case :                 return this.MessageIn;            default:              return this.MessageOut;         }     }     set { // switch again} } 

Authentication: E-mailing security codes vs clickable links

I’ve noticed a trend in how big companies (Amazon, Skype, and a few others I don’t remember in particular) handle e-mail authentication.

Rather than e-mailing clickable links with some single-use token, they’ve switched to short/readable security codes, which the user is expected to manually highlight, copy, and paste into a textfield on the page.

I can think of two motivations behind this change:

  1. A clickable link causes a “discontinuous” user experience. The user navigates around on one page, causes a recovery e-mail to be sent, but clicking the link opens a new tab while the previous one still lingers
  2. For security: to train users not to click links in e-mails sent by these companies

Is it one of these two reasons? Is it something else? Is there any literature that compares the two techniques?